Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / February 2008

Tip: Looking for answers? Try searching our database.

ANSI C to VC++ 2008

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
NvrBst - 29 Feb 2008 05:40 GMT
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
Carl Daniel [VC++ MVP] - 29 Feb 2008 06:11 GMT
> 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.
[quoted text clipped - 23 lines]
>    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
NvrBst - 29 Feb 2008 19:27 GMT
On Feb 28, 10:11 pm, "Carl Daniel [VC++ MVP]"
<cpdaniel_remove_this_and_nos...@mvps.org.nospam> 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.
[quoted text clipped - 52 lines]
>
> - 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.