I gave PGI Community Edition Version 17.4 for Windows x64 a try and experience several issues with code which compiles well on Linux. The environment is:
- Windows 10 Pro, Version 1607, 64-bit operatins system, x64-based processor
- Windows Software Development Kit - Windows 10.0.15063.13
- Microsoft Visual Studio Community 2015 Version 14.0.25431.01 Update 3
- pgcc 17.4-0 64-bit target on x86-64 Windows -tp haswell
Firstly isnan does not compile:
// test1.c
#include <math.h>
int main(void)
{
isnan(0.0);
}
PGI$ pgcc test1.c
PGC-S-0036-Syntax error: Recovery attempted by inserting ‘?’ before ‘:’ (test1.c: 5)
PGC-S-0039-Use of undeclared variable suppress (test1.c: 5)
PGC-S-0056-Attempt to call non-function (test1.c: 5)
PGC-S-0036-Syntax error: Recovery attempted by inserting ‘?’ before ‘:’ (test1.c: 5)
PGC-S-0056-Attempt to call non-function (test1.c: 5)
PGC/x86-64 Windows 17.4-0: compilation completed with severe errors
Then ULONG_MAX can’t be compared with ULLONG_MAX:
// test2.c
#include <limits.h>
int main(void)
{
#if ULONG_MAX == ULLONG_MAX
#endif
}
PGI$ pgcc test2.c
PGC-S-0027-Illegal integer constant: ffffffffffffffffui64 (test2.c: 5)
PGC-S-0254-Illegal number in directive (test2.c: 5)
PGC/x86-64 Windows 17.4-0: compilation completed with severe errors
The following fragment links on Linux but not on Windows:
// test3.h
inline int add(int a, int b);
static inline int add(int a, int b)
{
return a + b;
}
// test3a.c
#include "test3.h"
int sub(int a, int b)
{
add(a, -b);
}
// test3.c
#include "test4.h"
int main(void)
{
add(1, 2);
}
PGI$ pgcc -c test3a.c
PGI$ pgcc test3a.obj test3.c
test3.c:
test3.obj : error LNK2005: add already defined in test3a.obj
test3a.exe : fatal error LNK1169: one or more multiply defined symbols found
Since gcc emits a warning:
$ gcc -std=c11 -c test3a.c -o test3a.o
In file included from test3a.c:1:0:
test3.h:1:12: warning: inline function ‘add’ declared but never defined
inline int add(int a, int b);
^
$ gcc -std=c11 test3a.o test3.c -o test3
In file included from test3.c:1:0:
test3.h:1:12: warning: inline function ‘add’ declared but never defined
inline int add(int a, int b);
^
I think the code is not conform to C11. Nevertheless it runs on Linux.
Then some header files produce warnings:
// test4.c
#include <inttypes.h>
int main(void)
{
}
PGI$ pgcc test.c
PGC-W-0114-More than one type specified (C:\PROGRA~1\PGICE/win64/17.4/include/vcruntime.h: 220)
PGC-W-0143-Useless typedef declaration (no declarators present) (C:\PROGRA~1\PGICE/win64/17.4/include/vcruntime.h: 220)
PGC/x86-64 Windows 17.4-0: compilation completed with warnings
// test5.c
#include <windows.h>
int main(void)
{
}
PGI$ pgcc test2.c
PGC-W-0114-More than one type specified (C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/um\commdlg.h: 729)
PGC-W-0143-Useless typedef declaration (no declarators present) (C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/um\commdlg.h: 729)
PGC-W-0043-Redefinition of symbol, LPUINT (C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/um\imm.h: 45)
PGC/x86-64 Windows 17.4-0: compilation completed with warnings
And finally there is an issue with OpenCL:
// test6.c
#include <CL/cl.h>
int main(void)
{
}
PGI$ pgcc -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include" test6.c
PGC-W-0267-#warning – Need to implement some method to align data here (C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include\CL/cl_platform.h: 482)
PGC-W-0114-More than one type specified (C:\PROGRA~1\PGICE/win64/17.4/include/vcruntime.h: 220)
PGC-W-0143-Useless typedef declaration (no declarators present) (C:\PROGRA~1\PGICE/win64/17.4/include/vcruntime.h: 220)
PGC/x86-64 Windows 17.4-0: compilation completed with warnings
PGC-W-0114, PGC-W-0143 are Windows specific but PGC-W-0267 remains on Linux.
I wonder:
- How can I fix test1.c and test2.c?
- Can the header warning be safely ignored? Can they be avoided?
- Can the OpenCL warning be ignored, too?