WPS compilation error: PGC-F-0249 (byteswap.h)

I tried compiling the WPS package with WRF, and I get the following error:

pgcc -D_UNDERSCORE -DBYTESWAP -DLINUX -DIO_NETCDF -DIO_BINARY -DIO_GRIB1 -DBIT32 -D_GEOGRID -O -c cio.c

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
make[1]: [cio.o] Error 2 (ignored)

This is with WPS 2.2.1, and PGI Workstation 8.0-1 32-bit, on Fedora 10.


I took a look at the cio.c source file in the WPS/geogrid/src/ folder, and it has only the following includes:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

Did I miss yet more fine print in the installation guide? Or is this something wrong on the compiler end?

Hi Daniel_S,

I don’t have a system with Fedora 10 installed nor am I able to reproduce this error on any other system (the source compiles fine for me). So unfortunately, I don’t know why you are seeing this error.

Can you please compile this file with “-P” and then look at the resulting “cio.i” file to determine which file is including “bits/byteswap.h”?

I’ll try and get our IT department to install Fedora 10 on a system, but it most likely wont be until after the holidays. Note that since Fedora 10 was released after our 8.0 release, it is not a currently supported OS.

  • Mat

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.

Hi Daniel_S,

We got Fedora 10 installed here and it appears they have changed a few header files which will require us to change our “bits/byteswap.h” file.

In particular, they have updated the system “endian.h” file to directly include “bits/byteswap.h”. This means in our version of "bits/byteswap.h, “endian.h” needs to be added to the list of header files that are allowed to call it directly. So by changing line 20 of “/opt/pgi/linux86/8.0-1/include/bits/byteswap.h” from:

#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
#endif

to

#if !defined _BYTESWAP_H && !defined _NETINET_IN_H && !defined  _ENDIAN_H
# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
#endif

you can work around the problem.

I’ve added a technical problem report (TPR#15472) and send it on to engineering to have the problem corrected in a future release.

  • Mat

Ahh, thank you. This solved my problem quite nicely.

Hi Daniel,

We’ve updated the 8.0-4 PGI header files to include this change.

  • Mat