Closed soumyaranjansabat closed 3 years ago
Can you supply the command line args you fed to pcpp to yield this result please?
Was running it on default without any arguments . Just -o.
[Off-topic but I think might resolve the issue] Is there a way to not expand the macros / macro like functions in the generated file ?
test.h:
#define CONDITION_1 ON
#if ((CONDITION_1 == ON) || (CONDITION_2 == OFF))
Foo
#endif
I run:
pcpp -o test1.i test.h
test1.i:
#line 4 "test.h"
Foo
I run:
gcc -E -o test2.i test.h
test2.i:
# 1 "test.h"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<command-line>" 2
# 1 "test.h"
Foo
Looks to me pcpp is doing the right thing here?
ex :
#define MYVALUE 0x05
#define CONDITION_1 ON
if(MYVALUE > 0x01)
{
<code>
#if ((CONDITION_1 == ON) || (CONDITION_2 == OFF))
Foo
#endif
}
at present in the resultant output is,
if(0x05> 0x01)
{
<code>
Foo
}
Can the expansion of the macro be disabled like,
if(MYVALUE > 0x01)
{
<code>
Foo
}
Similarly for Macro like functions.
To get exactly what you want, you'll need to customise the preprocessor hooks. See https://ned14.github.io/pcpp/preprocessor.html#pcpp.preprocessor.PreprocessorHooks.
If you want some macros to be expanded but not others, the Readme on the front page tells you how.
If a condition as such :
define CONDITION_1 ON
if ((CONDITION_1 == ON) || (CONDITION_2 == OFF))