Craig's Yaroze Page

Code Warrior C++ : How to get it to work

Firstly, the only bit's that seem to be missing from Code Warrior's C++ are new and delete. There's also a couple of easy to fix problems with libps.h - we'll deal with those first.

Fixing libps.h

Edit your libps.h file as follows:

Find the start of the function prototypes (it'll be around line 360). Before the first prototype insert the line:

#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
extern "C" {

Now go to the end of the file and add the chunk below (just before the #endif):

#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)

Find the definition of delete() - it reffers to a filesystem function anyway. Replace it with the chunk below:

#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
extern int deletefile(char *);
extern int delete(char *);

Creating a working C++ project

I've produced a project that you can stick in your Stationary folder which will add a NetYarozeC++ project type.
Download it here: *download*

What this gives you is a new() macro that allocates the space for an object and a delete() macro that will invoke the destructor before freeing the object. Simple, but effective. This will get rid of the linker error that you normally get when compiling C++ code that tries to do dynamic object creation.
The only thing to remember is that you MUST include "cg_cpp.h" in every source file to ensure the macro's are included.