Jump to content
  • Advertisement
Sign in to follow this  
paul23

Main incompatibility of C code in C++

This topic is 3075 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

Well my question is simple: what are the main things one should watch out for when looking at C code to "port" them to C++ code?

Share this post


Link to post
Share on other sites
Advertisement
What do you mean exactly by "porting" C code to C++? Most modern C++ compilers support the relevant features of C99, meaning that C code will generally compile as C++. Cases where features exist in C99 but not in C++98/03, such as long long, are usually bridged by compiler extensions. Perhaps you're referring to the process of converting a procedural system into an object-oriented one?

Share this post


Link to post
Share on other sites
Quote:
Original post by paul23
Well my question is simple: what are the main things one should watch out for when looking at C code to "port" them to C++ code?


There are very little issues that you might encounter when compiling C as C++ (in terms of compiler errors). For example, if you have some really really old C then you might encounter the old-style function parameters:

func(a, b) // implicit int return type
// declaring the parameter types
int a;
char b;
{
if (b == 'a') return a;
return 42;
}

Which is not valid in C++.

Share this post


Link to post
Share on other sites
Quote:
Original post by Windryder
What do you mean exactly by "porting" C code to C++? Most modern C++ compilers support the relevant features of C99, meaning that C code will generally compile as C++. Cases where features exist in C99 but not in C++98/03, such as long long, are usually bridged by compiler extensions. Perhaps you're referring to the process of converting a procedural system into an object-oriented one?


Nah, just to those feature cases as you said.. - It's not that the code won't compile, I just want to know the differences..

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!