Class headers and #define

I have a strange problem:

I have in my file :

#define ptrMyClass MyClass::Instance()

meaning that I want every occurence of “ptrMyClass” replaced by
"MyClass::Instance()"

the file compiles normally but class dictionary generation dies with the following message:

mpiCC -DPARALLEL -DNDEBUG -O2 -Wall -fPIC -I/mnt/x1/home/sasy/root/include -I…/src/ -c LegsEvent.cxx

Generating DICTIONARY for LegsEvent.h
Error: class,struct,union or type MyClass not defined

I guess ROOTCINT somehow ignores #define ?

How do go around this ?

:open_mouth:

Hello Ardashev,

Your observation is correct. #define macro like that can not be handled by Cint. See cint/doc/limitati.txt in Cint source pacakge.

#define ptrMyClass MyClass::Instance()

Workaround depends on how you use this macro. I guess you have above line in a header file read by rootcint. If you only need to use ptrMyClass in compiled code, you can simply surround this line by
#ifdef.

#ifndef CINT
#define ptrMyClass MyClass::Instance()
#endif

If you want to use ptrMyClass in macro, sorry it is not possible now. Please use other notation.

Thank you
Masa Goto