You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am parsing a project which uses ifdefs. While using pcpp to test variants of the code, some classes were no longer being detected by cppheaderparser. This is because cppheaderparse will leave behind #line 2 where 2 is the line number wherever a preprocessor directive is processed/replaced.
While I'm not sure if #line is valid cpp syntax, I've determined the existence of the # does break cppheaderparser so a valid #define 1 also causes the behavior.
Specifically, the #define 1 below immediately after the class declaration but before the { will break parsing of the class. While this is a toy example and it won't break if the #define is after the {, this may be valid syntax if the class inheritance is controlled by an ifdef.
namespaceRE
{
classPlayerCharacter
#define 1 // This define breaks the discovery of PlayerCharacter. If this line is commented out, the class will be discovered.
{
}
}
The text was updated successfully, but these errors were encountered:
Thanks. I have a workaround where I strip out the #line using a regex so I'm unlikely to be able to really learn the code to do a PR. I did try cxxheaderparser at one point, but I believe it had an uncaught exception on a double template declaration and I at least could get past that part using cppheaderparser.
I just pulled the latest and it's crashing a bit earlier on that file due to the newline for the define. I'll open an issue. robotpy/cxxheaderparser#48
Problem description
I am parsing a project which uses ifdefs. While using pcpp to test variants of the code, some classes were no longer being detected by cppheaderparser. This is because cppheaderparse will leave behind
#line 2
where 2 is the line number wherever a preprocessor directive is processed/replaced.While I'm not sure if
#line
is valid cpp syntax, I've determined the existence of the#
does break cppheaderparser so a valid#define 1
also causes the behavior.Specifically, the
#define 1
below immediately after the class declaration but before the{
will break parsing of the class. While this is a toy example and it won't break if the#define
is after the{
, this may be valid syntax if the class inheritance is controlled by an ifdef.This was tested with the command line:
python -m CppHeaderParser.tojson processed_playercharacter.h > test_processed.json
Operating System
MacOS
Installed Python Packages
Reproducible example code
The text was updated successfully, but these errors were encountered: