Open alandtse opened 1 year ago
Weird. I miiiight be able to look at it next week, but no promises. Happy to accept a PR though.
Have you tried using cxxheaderparser for your use case?
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.
Was the cxxheaderparser bug this one: https://github.com/robotpy/cxxheaderparser/issues/20 ?
It may be the same root cause. I think it choked on something like this (but this is from memory): https://github.com/alandtse/CommonLibVR/blob/95c6de6bbee89d0195fd3e1ba0a469b44928e038/include/REL/Relocation.h#L139-L147
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. https://github.com/robotpy/cxxheaderparser/issues/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:
Operating System
MacOS
Installed Python Packages
Reproducible example code