Forums > Dev

the use of the #define _cplusplus

November 19, 2009 | 6:06 pm

I am experimenting making external in c++ with the max external…

Up until now I was encapsulating my main function in a extern "C" {}.. but I realize that alot of the cycling74 header have a if def _cplusplus… So does this means that if I do #define _cplusplus in before all my includes I don’t need to put my main in an extern "C" block? Of course I’ll only use c++ function in my main…

thks alot

Mani


November 20, 2009 | 3:05 pm

There is a C++ example in the SDK called "collect", which you may find helpful.

You do not need to define the c++ preprocessor symbol — compilers set this automatically and if you change it then it could cause you trouble down the road.

Cheers,


November 20, 2009 | 7:49 pm

Wow thanks you are right!

it is because I didn’t like to put all my software in an extern "C" block so i did

namespace C74
{
   // Max includes
   extern "C"
   {
      #include "ext.h"   // standard Max include, always required
      #include "ext_obex.h" // required for new style Max object
      #include "ext_strings.h"
      #include "ext_common.h"
      #include "commonsyms.h"
   }
}; // namespace MaxMspJitter

and it all seam to work!

thanks alot!

Mani



+1m
November 23, 2009 | 1:53 pm

The Cycling-provided header files (ext.h and friends) should have all of the extern "C" work done for you already, so there really isn’t any need for you to do it manually.

Cheers,
Tim


Viewing 4 posts - 1 through 4 (of 4 total)