defines inside class body #5

Kakadu opened this Issue Oct 18, 2010 · 3 comments

2 participants


$ cat class.cpp 
#define SLOT
class A {
        public SLOT:
          void foo(int);
int main() {}
$ ../../pfff -dump_cpp_ml class.cpp > /dev/null
parse error 
 = File "class.cpp", line 3, column 8,  charpos = 31
    around = 'SLOT', whole content =    public SLOT:
ERROR-RECOV: found sync '}' at line 5
ERROR-RECOV: found sync bis, eating } and ;
badcount: 4
bad: #define SLOT
bad: class A {
BAD:!!!!!       public SLOT:
bad:      void foo(int);
bad: };
Facebook member

Yes. This is normal. The C/C++ parser in pfff try to parse as-is the source code, without calling first cpp. The reason is that in a refactoring context, you can not call cpp because cpp then expand all the macros and ifdefs and modifying the expanded code would not let you back propagate easily the modification to the original source (before expansion). To still be usable the C++ parser recognize a few macros idioms
such as FOR_EACH, attributes, etc. This is documented here:

Because it would be hard to handle all the possible idioms, the parser can be helped
by the user by listing the set of macros that would help the parser. I will write
a wiki page about it.

Thanks for the "bug" report.

Facebook member

FYI the documentation will be in:


Ok, I understand.

@aryx aryx closed this Mar 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment