gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > Switching from C to C++

#24810 - Kris Allen - Wed Aug 11, 2004 9:45 pm

I've been using C for GBA games so far, but I'd like to switch to C++ instead (I'm missing a few features offered by it).
How would I do this? I've never used GCC before, since I'm used to using Visual C++'s compiler. I tried renaming my source files to .cpp but I end up with a handful of 'unidentified function' errors with rand,memcpy, etc, and nothing I #include seems to fix it. Am I doing this right?

Thanks in advance

#24814 - tepples - Wed Aug 11, 2004 10:09 pm

In C++, you have to change your #includes of standard C header files, from <foo.h> to <cfoo>.
Code:
#include <stdlib.h>  // in C
#include <cstdlib>  // in C++

_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#24815 - dagamer34 - Wed Aug 11, 2004 10:12 pm

Why the sudden change to C++?
_________________
Little kids and Playstation 2's don't mix. :(

#24818 - Kris Allen - Wed Aug 11, 2004 10:22 pm

I couldn't get member functions or references (as function parameters) to work - not sure if C has them or not but the syntax i'm used to just brought errors up

thanks tepples, works great now

#24826 - dagamer34 - Thu Aug 12, 2004 12:03 am

Kris Allen wrote:
I couldn't get member functions or references (as function parameters) to work - not sure if C has them or not but the syntax i'm used to just brought errors up

thanks tepples, works great now


Yea, that's pretty much all I use C++ for. I might use classes every once in a while, but not for underlying library code.
_________________
Little kids and Playstation 2's don't mix. :(