473,327 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

ANSI C to VC++ 2008

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
2 2574
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

143
by: suri | last post by:
Hello I downloaded glibc and tried looking for the code that implements the sine function i couldnt find the file. i went to the math directory and found math.h.. i guess that needs to be...
5
by: mmxbass | last post by:
In Visual Studio 2005, how can I set my project to be a strict ANSI-C project with absoloutly nothing else? I don't want my project to even compile if it contains any C++ or non-ANSI code.
83
by: sunny | last post by:
Hi All What is C99 Standard is all about. is it portable, i mean i saw -std=C99 option in GCC but there is no such thing in VC++.? which one is better ANSI C / C99? can i know the major...
7
by: Norman Diamond | last post by:
A project depends on VC runtime from Visual Studio 2005 SP1, and DotNet Framework 2. Options are set in the setup project properties, so if these two dependencies are not already installed then...
53
by: Edward Diener | last post by:
Why bother having Stan Lippman and Herb Sutter created a C++/CLI language for .Net development when Microsoft, and the VC++ development team, are so clearly intent on limiting .Net development with...
0
by: johntheys | last post by:
I am porting an old Borland C++ program to a VC++ 2008 CLR/Windows Form App. It has a home-grown script language used to set parameters, etc that can be modified by non-programmers. I would like to...
2
by: goo.one1 | last post by:
Hi All, I'm looking for info on how to port VC++ 6 code/projects to VC++ 9 (2008). I noticed that there is a converter built-in for Visual *BASIC* to convert from VS6 to 9... I have found...
6
by: Peng Yu | last post by:
Hi, ANSI and GNU C are different in some delicate aspects (I'm not sure about C++). For example, M_PI is not in ANSI C but in GNU C. Of course, to make my program most portable, I should go...
2
by: Peter Duniho | last post by:
On Fri, 18 Jul 2008 10:41:23 -0700, jmDesktop <needin4mation@gmail.com> wrote: Well, that's an interesting example, if for no other reason than that the DirectShow video capture stuff is a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.