pgcc / pgc++ -E treats .c/.cc and .h/.hpp files differently


PGI’s preprocessing shows odd behavior.

$ echo “#include <stdio.h>” > main.c
$ echo “#include <stdio.h>” > foo.h
$ echo “#include ” >
$ echo “#include ” > foo.hpp

$ pgcc -E main.c

Works, but omits file information from the preprocessing (from which file a declaration came) (pgcc -### -E foo.h also yields a completely different call than for main.c)
$ pgcc -E foo.h

We want this file information (and intel and gcc supply it)

$pgc++ -E

Fails, with error:
PREPRO-F-0206-Can’t find include file iostream (foo.hpp: 1)
PREPRO/x86-64 Linux 16.4-0: compilation aborted
(And again $ pgc++ -### -E foo.hpp looks very different from
$ pgc++ -E foo.hpp

Although the four files have the same content, the preprocessor is invoked differently.

  • It doesn’t give file information for headers
  • It fails for a c++ header

Gcc, and intel are fine with this.
Personally, I can’t see the reason why this difference exists.

We don’t really want to add a workaround for our tool to rename a file, just because one compiler can’t preprocess headers.

Is this intended, or should I file a support request / bug?

Thanks for your help and best regards,