simplecpp icon indicating copy to clipboard operation
simplecpp copied to clipboard

Possible fundamental flaw in order of pre-processing?

Open SimonFraser11 opened this issue 7 years ago • 4 comments

Using the following code snippet:

#define TARGS4 T1,T2,T3,T4
#define FOOIMPL(T__CLASS, TARGS) void foo(const T__CLASS<TARGS>& x) { }
#define FOOIMPL_4(T__CLASS)      FOOIMPL(T__CLASS, TARGS4)
FOOIMPL_4(y)

both gcc and Visual C++ give the following output:

void foo(const y<T1,T2,T3,T4>& x) {}

However CppCheck via simplecpp gives the following error:

[file.cpp:3]: (error) failed to expand 'FOOIMPL_4', Wrong number of parameters for macro 'FOOIMPL'

I'm unsure but this might be related to issues #40 , #79 and #109. Could it be that simplecpp is trying to expand pre-processor arguments too early?

SimonFraser11 avatar Dec 28 '17 12:12 SimonFraser11

Could it be that simplecpp is trying to expand pre-processor arguments too early?

Sure there is a problem to fix. My feeling is that this is very hard to get perfect. As far as I have seen, the rules are not always entirely consistent.

danmar avatar Dec 29 '17 22:12 danmar

I closed wrong issue by mistake

danmar avatar Jan 13 '18 21:01 danmar