pcpp
pcpp copied to clipboard
Header with only macro definitions are silently processed without leaving a trace in the final preprocessed output.
I tried with 4 files as below:
Folder structure:
C:\MISC\PCPP.TEST
a.c
h1.h
h2.h
h3.h
(a.c)
#include "h1.h"
#include "h2.h"
#ifdef H3
#include "h3.h"
#endif
void main()
{
}
(h1.h)
void f_h1()
{
}
(h2.h)
#define H3
(h3.h)
void f_h3()
{
}
Then I run pcpp a.c > pp.a.c
, the result is:
#line 1 "h1.h"
void f_h1()
{
}
#line 1 "h3.h"
void f_h3()
{
}
#line 8 "a.c"
void main()
{
}
We can see, the macro H3
defined in h2.h
is effective. But there's no trace of h2.h
being processed in the final ouput pp.a.c
file.
I compared it to the result of gcc
, I run gccc -E a.c > gcc.pp.a.c
, the result is:
# 1 "a.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "a.c"
# 1 "h1.h" 1
void f_h1()
{
}
# 2 "a.c" 2
# 1 "h2.h" 1 <================= HERE, the processing of h2.h is shown.
# 3 "a.c" 2
# 1 "h3.h" 1
void f_h3()
{
}
# 6 "a.c" 2
void main()
{
}
So I think maybe it is nice for pcpp
to be more explicit to list the h2.h
in the final output.
I've had a few people complain about this, even though this behaviour is perfectly standards conforming. I'll look into it.