On 11/ 9/12 11:34 AM, Gabriel Dos Reis wrote:
commit 71f7ab6a05448e48a3b5741bb8a5ef57701e9c70
Author: Karel Gardas<karel.gar...@centrum.cz>
Date: Thu Nov 8 22:04:44 2012 +0100
define own version of PRIdPTR on platform where its not available
Note that PRIdPTR is considered as linux-ism so it's not available on
platforms
like Solaris, although some other free Unix(-like) OSes apparently supports
it too.
The log comment is not correct.
In fact, it is ISO C99 standard; some old proprietary C system headers
not have it (13 years later) but it is not linux-ism.
Hello,
I've analyzed the issue and it looks like, Solaris is defining PRIdPTR
in sys/int_fmtio.h, this file is thorough sys/inttypes.h included into
inttypes.h when !defined(_XOPEN_SOURCE) || defined(_XPG6) ||
defined(__EXTENSIONS__) -- unfortunately GHC's PosixSource.h which is
included before inttypes.h in mkDerivedconstants.c defines _XOPEN_SOURCE
for Solaris which means PRdPTR is not defined as the sys/int_fmtio.h is
not included under such conditions.
Now, I'm not expert in C nor in C99, but what does it mean? That Solaris
is strict and does not consider _XOPEN_SOURCE to be C99?
Small test:
#define _XOPEN_SOURCE
#include <stdio.h>
#include <inttypes.h>
int
main()
{
printf("%s\n", PRIdPTR);
return 0;
}
reveals that it cannot be compiled with gcc -std=c99 test.c due to
following error:
In file included from /usr/include/stdio.h:15:0,
from test.c:3:
/usr/include/sys/feature_tests.h:354:2: error: #error "Compiler or
options invalid for pre-UNIX 03 X/Open applications and pre-2001 POSIX
applications"
test.c: In function ‘main’:
test.c:9:16: error: ‘PRIdPTR’ undeclared (first use in this function)
test.c:9:16: note: each undeclared identifier is reported only once for
each function it appears in
and of course it cannot be compiled with simple gcc test.c due to:
test.c: In function ‘main’:
test.c:9:16: error: ‘PRIdPTR’ undeclared (first use in this function)
test.c:9:16: note: each undeclared identifier is reported only once for
each function it appears in
When I remove _XOPEN_SOURCE definition, then the compilation with or
without -std=c99 goes fine. To me it looks like _XOPEN_SOURCE is kind of
in conflict with C99 -- at least on Solaris. The question is if Solaris
team is right here or wrong here and how other platforms use/support this...
But most important question is to undefine _XOPEN_SOURCE or define
either _XPG6 or __EXTENSION__ just on Solaris? What's the most cleanest
solution?
Thanks for any idea!
Karel
_______________________________________________
Cvs-ghc mailing list
Cvs-ghc@haskell.org
http://www.haskell.org/mailman/listinfo/cvs-ghc