I tried a smaller test file with only:
// test.c
#include <stdlib.h>
//#include <stdio.h>
//#include <string.h>
and was able to reproduce the same error.
Using -P stripped out a little too much to easily tell what was coming from where, but I liked the idea, and noticed the -dI option. Here’s some abridged output using “pgcc -dI test.c”:
// test.c:1
#include /opt/pgi/linux86/8.0-1/include/stdlib.h
// /opt/pgi/linux86/8.0-1/include/stdlib.h:9
#include_next /usr/include/stdlib.h
// /usr/include/stdlib.h:320
#include /opt/pgi/linux86/8.0-1/include/sys/types.h
// /opt/pgi/linux86/8.0-1/include/sys/types.h:215
#include /usr/include/endian.h
// /usr/include/endian.h:61
#include /opt/pgi/linux86/8.0-1/include/bits/byteswap.h
PGC-F-0249-#error – “Never use <bits/byteswap.h> directly; include <byteswap.h> instead.” (/opt/pgi/linux86/8.0-1/include/bits/byteswap.h: 21)
PGC/x86 Linux 8.0-1: compilation aborted
I also noticed a
#ifdef __USE_BSD
line before a couple of blocks in that include chain.
I also got similar errors when recompiling NetCDF 4 using the instructions for an older version of the compiler (and an older version of NetCDF). Mind you, I encountered a few other errors first. On the first go, the configure script failed with:
checking size of short… 0
checking size of int… 0
checking size of long… 0
checking size of float… 0
checking size of double… 0
checking size of off_t… configure: error: cannot compute sizeof (off_t)
See `config.log’ for more details.
Removing the CC environment variable (and removing or adjusting CFLAGS too), and the configure script then runs fine, but then when I run make I get the same error above about byteswap.h from pgCC.
without any environment variables set, it builds fine, but it seemed to be using the system cc compiler, and pgf95.