Thursday, 15 August 2013

Macro issues in C++ -


I am trying to apply some code that is working for other people. I am using Visual Studio 2013, but I believe they are using a different compiler.

  #ifndef SAFE_DELETE #define SAFE_DELETE (x) / if (x! = NULL) Everything in the code is working properly expect a handful of macros.  / {/ Delete x; / X = null;   or  error C2059: syntax error: 'if'       P> 

Not surprisingly, I get an error when trying to use it:

  SAFE_DELETE (* this); // "Expect an Expression"  

The namespace where I define this macro is shared with the rest of my part, and the macro is not used anywhere else. There are no other syntax errors, including it and commenting on SAFE_DELETE (* this); produces the code that will compile Additionally, the macro works with the code from the macro as well as the place of the call.

I tried to redefine the function:

  #ifndef SAFE_DELETE #define SAFE_DELETE (X) / X = zero; / #endif  

This error generates error: There is no storage class or type specifier in this declaration . It makes me believe that in some way it is not being called in any class, yet it is very clearly.

What could be the issue? In addition, how is it possible that it was compiled for someone else?

You do not want to continue a line of a backslash ( \ ), Forward slash ( / ).


1 comment: