By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,934 Members | 1,692 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,934 IT Pros & Developers. It's quick & easy.

ANSI C to VC++ 2008

P: n/a
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
Feb 29 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
NvrBst wrote:
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
Feb 29 '08 #2

P: n/a
On Feb 28, 10:11*pm, "Carl Daniel [VC++ MVP]"
<cpdaniel_remove_this_and_nos...@mvps.org.nospamwr ote:
NvrBst wrote:
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- 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
Feb 29 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.