Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am compiling an old C application using SUN CC compiler,I am getting an error on the header file version.h. It seems that the compiler cannot recognizetheykey word"const" and it is expecting some other character instead of it

version.h

#include <stdio.h>
#include <string.h>
const char* mpszFileVersion[] = {
  "         ParamFile/ParamFile.c: ?",
  "  GenericPart/WriteLogString.c: ?",
  "      GenericPart/MainCommon.c: ?",
  "GenericPart/RunFileProcessor.c: ?",
  "GenericPart/InitFileProcessor.c: ?",
  "     GenericPart/ControlFile.c: ?",
  "            GenericPart/Main.c: ?",
  "             Utility/Utility.c: ?",
  "             ToolBox/ToolBox.c: ?",
  "Configuration/LoadMainConfig.c: ?",
  "         ParamFile/ParamFile.h: ?",
  "GenericPart/FileProcessorStruct.h: ?",
  "FileProcessor/FileProcessorList.h: ?",
  " FileProcessor/FileProcessor.h: ?",
  "           GenericPart/DbBee.h: ?",
  "      GenericPart/MainCommon.h: ?",
  "  GenericPart/WriteLogString.h: ?",
  "     GenericPart/ControlFile.h: ?",
  " GenericPart/InputFileStruct.h: ?",
  "             Utility/Utility.h: ?",
  "             ToolBox/ToolBox.h: ?",
  "Configuration/LoadMainConfig.h: ?",
  "",
};

error message

"./GenericPart/MainCommon.h", line 64: Warning (Anachronism): Attempt to redefine DEBUG without using #undef.
"./version.h", line 3: Error: "}" expected instead of "const".
"./version.h", line 3: Error: "," expected instead of "const".
"./version.h", line 4: Error: Use ";" to terminate declarations.
"./version.h", line 4: Error: A declaration was expected instead of ",".
"GenericPart/MainCommon.c", line 215: Error: The function "AtessPrintFileVersion" must have a prototype.
"GenericPart/MainCommon.c", line 1211: Warning (Anachronism): Formal argument 3 of type extern "C" void*(*)(void*) in call to pthread_create(unsigned*, const _pthread_attr*, extern "C" void*(*)(void*), void*) is being passed void*(*)(void*).
5 Error(s) and 2 Warning(s) detected.
gmake: *** [GenericPart/MainCommon.o] Error 5

Any help to solve this error will be appreciated.

Thanks

share|improve this question
4  
You have an extraneous comma on your last element. – Rapptz 35 mins ago
... and if that doesn't fix it, the first few errors look like your header files are broken. Make sure you can compile just the first two lines of this – Rup 34 mins ago
4  
@Rapptz: Trailing commas are legal C++. – Jesse Good 33 mins ago
Have you made any change in string.h? – Dayal rai 33 mins ago
3  
The error is not here, but in the file that includes version.h, or in a previously included file. – interjay 30 mins ago
show 5 more comments

put on hold as off-topic by Jeffrey, Mark Ingram, Armen Tsirunyan, Rapptz, billz 26 mins ago

If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

If the compiler doesn't understand const, then remove it, or better, #define it away with some pre-processor symbols to preserve it for other platforms.

However, are you certain it's not something else in the include chain causing you issues? The warning in GenericPart/MainCommon.h is highly suspicious. Does that file directly include version.h?

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.