This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Prototype initstate() etc. if _XOPEN_SOURCE is defined appropriately


On 13/11/2013 14:37, Jon TURNEY wrote:

Not sure if this is wanted, but mesa likes to compile with '-std=c99
D_XOPEN_SOURCE=500', which leads to exciting crashes on x86_64 because
initstate() is not prototyped.

2013-11-13  Jon TURNEY  <jon.turney@dronecode.org.uk>

	* include/cygwin/stdlib.h(initstate, random, setstate, srandom) :
	Prototype if not __STRICT_ANSI__ or _XOPEN_SOURCE is defined appropriately.

It seems this doesn't do the correct thing if _GNU_SOURCE is defined (which is supposed to imply _XOPEN_SOURCE)

Attached is an additional patch which instead includes sys/cdefs.h, and uses __XSI_VISIBLE.

$ cat test.c

#include <stdlib.h>

int main()
{
 return random();
}

before:

$ gcc test.c -Wall -ansi -D_GNU_SOURCE
test.c: In function âmainâ:
test.c:6:2: warning: implicit declaration of function ârandomâ

after:

$ gcc test.c -Wall -ansi -D_GNU_SOURCE

Attachment: stdlib.h.patch
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]