ANSI C to VC++ 2008


N

NvrBst

I'm not too much of a C++ programmer but I have a bunch of C programs
(they compile with GNU) and want to get them to compile in VC++ 2008.

In Unix I go "./configure" and it makes a "Makefile". I then do
"make" and when thats done I do "make install".

Is there some way to easily get this type of project working in VC++
2008? I do "New > Project From Exsisting Code > Use VIsual Studio:
Console application". And I give it the Include folder that comes
with the program.

When I try to compile I get about 75 errors. Mostly all are
duplicates but is there some kind of switch I should be setting so
that VC++ 2008 will compile ANSI C source?


50% of the errors are these:

error C2054: expected '(' to follow 'inline'
error C2085: 'imax' : not in formal parameter listError
error C2143: syntax error : missing ';' before '{'

The 3 errors point to the same inline function which is (the project
uses about 10 of these functions all getting the same errors)

static inline int imax(int a, int b) {
return a > b ? a : b;
}

and its found in a header file. Anyone know how I fix this? Or would
need more information?

Note: The project basically compiles two DLL files in a src folder and
then compiles a EXE in the examples folders (which links the 2
DLL's). There is only about 300KBs of source files.

I also see a "Makefile project" in VC++ 2008, but I don't know how to
use this, or if it'd even be usefull for me?

Basically if any one has any pointers a general outline on how I can
get C ANSI to compile in VC++ 2008 I'd be very greatful :)

Thanks, NB
 
Ad

Advertisements

C

Carl Daniel [VC++ MVP]

NvrBst said:
I'm not too much of a C++ programmer but I have a bunch of C programs
(they compile with GNU) and want to get them to compile in VC++ 2008.

In Unix I go "./configure" and it makes a "Makefile". I then do
"make" and when thats done I do "make install".

Is there some way to easily get this type of project working in VC++
2008? I do "New > Project From Exsisting Code > Use VIsual Studio:
Console application". And I give it the Include folder that comes
with the program.

When I try to compile I get about 75 errors. Mostly all are
duplicates but is there some kind of switch I should be setting so
that VC++ 2008 will compile ANSI C source?


50% of the errors are these:

error C2054: expected '(' to follow 'inline'
error C2085: 'imax' : not in formal parameter listError
error C2143: syntax error : missing ';' before '{'

The 3 errors point to the same inline function which is (the project
uses about 10 of these functions all getting the same errors)

static inline int imax(int a, int b) {
return a > b ? a : b;
}

That's C99 code - VC++ does not support C99 (other than a few things, like
long long).
and its found in a header file. Anyone know how I fix this? Or would
need more information?

You'll need to modify the code to make it valid C89 or valid C++ 98. To
compile all the code as C++, rename the files .cpp instead of .c - that
could solve some of your problems, and/or create many more.
Note: The project basically compiles two DLL files in a src folder and
then compiles a EXE in the examples folders (which links the 2
DLL's). There is only about 300KBs of source files.

I also see a "Makefile project" in VC++ 2008, but I don't know how to
use this, or if it'd even be usefull for me?

It's not - ignore it.
Basically if any one has any pointers a general outline on how I can
get C ANSI to compile in VC++ 2008 I'd be very greatful :)

You're on the right track - it looks like it's just the lack of C99
compatibility that's tripping you up.

-cd
 
Ad

Advertisements

N

NvrBst

That's C99 code - VC++ does not support C99 (other than a few things, like
long long).




You'll need to modify the code to make it valid C89 or valid C++ 98.  To
compile all the code as C++, rename the files .cpp instead of .c - that
could solve some of your problems, and/or create many more.





It's not - ignore it.




You're on the right track - it looks like it's just the lack of C99
compatibility that's tripping you up.

-cd- Hide quoted text -

- Show quoted text -

Ahh thank you :) I changed them to cpp and then it complained about
no "stdbool.h" which I commented out and added my own "fmax(double,
double)" function, and now it compiles :) I'll try some of the others
now :)

Thanks Again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top