0

My current job at the university is to port a C program from MinGW (windows) to Visual Studio (nmake).

I have got a valid "makefile.vc" file for a very similar C program. My approach was to adopt the Makefile (i.e. "makefile.vc") to the program I need to port.

All but four C files seem to compile fine. Those four files have various errors for example, syntax errors and "unknown size".

Should I continue with my approach to change the Makefile or use CMAKE instead of nmake?

Is there a tutorial or any other pointer on porting a C program from MinGW/gcc to nmake?

typedef struct {
  A_TypeConverter *converter;
  char *domain;
} enumeratorConverterEntry;
static enumeratorConverterEntry enumeratorConverterEntries[]; /* line 186 */

error:

f.c(186) : error C2133: 'enumeratorConverterEntries' : unknown size


typedef struct AsmInstructionInfo {
  int flags;
  CONST char **argTypes; /* line 7 */
  int minArgs;
  int maxArgs;
  int cArgs;
} AsmInstructionInfo;

error:

fAssemble.c(7) : error C2061: syntax error : identifier 'CONST'

..

/* file fStack.c: */

#ifdef CHECK_ACTIVATION_COUNTS

/* code */
#endif

/* more code */

void fShowStack(l_Interp *interp) { /* line 94 */
    l_CallFrame *framePtr;

/* more code */

error:

 fStack.c(94) : error C2143: syntax error : missing ')' before '*'
 fStack.c(94) : error C2143: syntax error : missing '{' before '*'
 fStack.c(94) : error C2059: syntax error : ')'
 fStack.c(94) : error C2054: expected '(' to follow 'interp'
3
  • 1
    Your problems seems not in make/nmake but in C program itself. Can you show exact error mesages and related fragments of code?
    – osgx
    Dec 15, 2011 at 19:25
  • You can't define in C arrays like this. Your errors has nothing to do with the porting. Dec 15, 2011 at 19:36
  • thanks for your info! the very same file when compiled with MinGW... it works 100% and all test cases (~3000) pass. it also compiles with gcc on linux. I am really missing here something.
    – mrsteve
    Dec 15, 2011 at 19:39

2 Answers 2

1
static enumeratorConverterEntry enumeratorConverterEntries[]; /* line 186 */

That looks like a valid incomplete, forward declaration of an array, which would be valid syntax, except I think for the static qualifier. I don't have a copy of the 'C' standard in front of me, but reading between the lines on the results of Googling "forward declaration of static array" seems to indicate that an incomplete definition of a static array results in undefined behavior, so Microsoft and GNU are legitimately entitled to do whatever they want with it. GNU accepts it, and Microsoft rejects it. As Mark Wilkins points out you should be make the Microsoft compiler happy by replacing it with:

extern enumeratorConverterEntry enumeratorConverterEntries[]; /* line 186 */

In general it's worth noting that the Microsoft compiler only supports the C89 standard, while the GNU compiler supports portions of the C99 standard, and several of their own extensions, depending on the arguments to the compiler.

The errors in fAssemble.c and fStack.c look like one or more preprocessor files are missing or incomplete. You should search your source to find out where CONST and l_Interp are defined, and then figure out why they are not being picked up in the files where the errors are occurring.

1

I just now tried out that array declaration with MinGW, and it does compile. To make it link, though, it needs the array to be defined elsewhere. The result is that it appears to be the same as the extern storage class:

extern enumeratorConverterEntry enumeratorConverterEntries[];

I'm not sure if there are other subtleties associated with the original declaration using a static storage class for the global.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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