[MLton] C99 runtime problems on Darwin

Wesley W. Terpstra terpstra@gkec.tu-darmstadt.de
Thu, 23 Dec 2004 01:08:36 +0100


On Wed, Dec 22, 2004 at 03:20:28PM -0800, Stephen Weeks wrote:
> It seems to me it would be an improvement to put the following three
> #defines at the beginning of platform.h, rather than sprinkling them
> through every C file.
> 
> 	#define _ISOC99_SOURCE
> 	#define _POSIX_C_SOURCE 200112L
> 	#define _BSD_SOURCE

These #define's must appear before including any system header.
They are also somehow documenting the source language of a C file.

I don't recall exactly why, but this is how its always done in C.
I suppose if you promise to include platform.h at the top of every C file.
And put the defines at the top of platform.h, it _might_ be ok.

You have to absolutely be sure of this, so no including platform.h in other
headers and thinking you only need the other header.

> I don't see what we gain by including subsets of these in some files.

Yeah, you're probably right.
They should all be POSIX 200112; it's simpler.
It would only make sense if sometimes you weren't compiling Posix/.

The _BSD_SOURCE is not necessary from what I read, just till platforms
actually conform to the standard properly.

> I like to think of platform.h as specifying the platform that the rest
> of the runtime expects.  That way, we can make changes in one place
> instead of a hundred (as we just had to do with the above patch).

I understand your motivation.
However, I don't know what's best since I forget why this is the convention.

-- 
Wesley W. Terpstra