Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

defines inside class body #5

Closed
Kakadu opened this Issue · 3 comments

2 participants

@Kakadu

$ 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: };
$
@aryx
Owner

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:
http://padator.org/papers/yacfe-cc09.pdf

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.

@aryx
Owner

FYI the documentation will be in: http://github.com/facebook/pfff/wiki/Preprocessor

@Kakadu

Ok, I understand.

@aryx aryx closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.