Compiler warnings when using math.h

I’m trying to figure out why pgcc gives the following warnings when compiling any code I write that includes math.h:

PGC-W-0266-Null argument to macro (/usr/include/bits/mathcalls.h: 55)
PGC-W-0266-Null argument to macro (/usr/include/bits/mathcalls.h: 55)
PGC-W-0266-Null argument to macro (/usr/include/bits/mathcalls.h: 55)
PGC-W-0266-Null argument to macro (/usr/include/bits/mathcalls.h: 57)
PGC-W-0266-Null argument to macro (/usr/include/bits/mathcalls.h: 57)
PGC-W-0266-Null argument to macro (/usr/include/bits/mathcalls.h: 57)

This is only a sample of the warnings, the total number of warnings amount to hundreds of lines of the same warning with a different line number for mathcalls.h. After some digging, I’ve found that mathcalls.h is used in the math.h file and holds the definitions of the math functions. The line numbers in the warnings correspond to each of the definitions of the math functions. This warning only occurs when the when i use the -Xa switch when i compile. I was originally trying to find out why this warning was occurring in a large program I’ve begun working on, but based on those warnings, the warning is independent of any code in that program, so I copied a program from the user manual for the PGI compilers, from the section where it discusses using builtin math functions in c/c++. I used this test program to confirm that the warnings had nothing to do with the code of the other program, since the exact same warnings occur when I compile the test program using the ansi switch, -Xa (all I have to do to get the warnings is #include<math.h>).

The large program I was working on is written in ANSI C89, which is why the -Xa is needed when we compile it with pgcc. It compiles and runs correctly with various other compilers including gcc and MS Visual Studio (using the required switches for those compilers).

The machine I am compiling on is running Centos 4.3, a clone of RedHat Enterprise 4.

Any ideas why am I getting these warnings and how do I correct them?

Hi mmartin,

The warning occurs because in the Linux system header file bits/mathcalls.h there are several marcos which are are missing an argument. For example:

__MATHCALL (acos,, (_Mdouble_ __x));

In ANSI C89, this behaviour is undefined, hence the preprocessor issues a warning. C99 clarified this issue and allows empty macro arguments. Unfortunately, you will need to either disable warnings, “-w”, or ignore the errors.

  • Mat