Skip to content

Header with only macro definitions are silently processed without leaving a trace in the final preprocessed output. #35

@smwikipedia

Description

@smwikipedia

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions