• Advertisement

Archived

This topic is now archived and is closed to further replies.

-=<C vs. C++>=-

This topic is 5952 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anyonw know anything that changes in the code when i use c++ instead of c, like opimization?

Share this post


Link to post
Share on other sites
Advertisement
Not a whole lot of difference - most C compilers are C++ compilers anyway these days.

Probably the most substantial difference will be if you use RTTI and exceptions, the compiler will create traceback tables in your functions, and extra data for the classes you use.

--

MP3 Dancer

Get A Stripper on your desktop

Share this post


Link to post
Share on other sites
Nah you shouldn''t have to change your code. If you''re linking .c files to .cpp files you might have problems with the way the compiler mangles function names internally.

Doing a web search for extern "C" will help you if you run into this.

Oh, and ads in posts? Isn''t that "a bit" lame?

Share this post


Link to post
Share on other sites
Hmm, if you''re using non-ANSI features of C, like function prototypes without parameters, or the ''parameters of a function definition in a declaration block'' thing, then C++ will choke on that. C++ will also be more strict about implicit casting and undeclared functions.

  
int foo ();
int foo (x, y, z)
int x, y, z;
{
printf("hello, world");
}


That is valid in non-ANSI C, but invalid in C++. If you''re using ANSI C, however, you might not notice that much difference. One thing of note is that you can''t have a struct with the same name as a typedef, for example. That''s not really an issue, because you shouldn''t be doing that anyway.

All your bases belong to us

Share this post


Link to post
Share on other sites

  • Advertisement