From: Arthur N. <ac...@ca...> - 2007-09-27 21:18:54
|
stddef.h seems to go #define NULL __null when you are in C++ mode. specstrings.h goes #define __null and that is included along with a load of windows headers. If both of these are used together NULL turns into nothing and misery results. By commenting out the line in specstrings.h my code (well actually it is the FOX windows toolkit) gets on a lot better, so I am not very upset about this! So thanks again for all you are doing. Arthur |
From: NightStrike <nig...@gm...> - 2007-09-27 21:25:20
|
On 9/27/07, Arthur Norman <ac...@ca...> wrote: > stddef.h seems to go > #define NULL __null > when you are in C++ mode. > > specstrings.h goes > #define __null > and that is included along with a load of windows headers. > > If both of these are used together NULL turns into nothing and misery > results. > > By commenting out the line in specstrings.h my code (well actually it is > the FOX windows toolkit) gets on a lot better, so I am not very upset > about this! So thanks again for all you are doing. Arthur Are you suggesting something involving #ifdef __null? |
From: Arthur N. <ac...@ca...> - 2007-09-28 07:54:51
|
On Thu, 27 Sep 2007, NightStrike wrote: > On 9/27/07, Arthur Norman <ac...@ca...> wrote: >> stddef.h seems to go >> #define NULL __null >> when you are in C++ mode. >> >> specstrings.h goes >> #define __null >> and that is included along with a load of windows headers. >> >> If both of these are used together NULL turns into nothing and misery >> results. >> > > Are you suggesting something involving #ifdef __null? > It looks to me as if the g++ world and the Microsoft world each introduced a new private keyword "__null", with g++ using it for NULL in place of 0 so they could do better error reporting, and the Microsoft world adding not just __null but loads of other things as decorations again to help with performance and diagnostics. I can find http://msdn2.microsoft.com/en-us/library/aa383701.aspx which web page does not seem to mention "__null" as one of them, but the Windows DDK header set goes #define __null __declspec("SAL_null") In the rest of their headers they have a number of places where they say eg WinInet.h: __null LPVOID lpGroupAttributes, WinInet.h: __null LPDWORD lpcbGroupAttributes, to flag up that some essentially unused or reserved field is expected to be NULL. In the DDK I have installed only WinInet.h seems to use __null, but potentially user code could. GCC said (void *)0 is no longer considered a null pointer constant; NULL in is now defined as __null, a magic constant of type (void *) normally, or (size_t) with -ansi. as of around 2.8.0. I expect really only macroexpansion NULL=>__null matters and hardly any users use __null directly (?). So g++ and Microsoft appear to me to have a genuine conflict by way of a name clash in private extensions to the language, both introduced with the admirable intent of improving error checking. I can see two ways around this. The first is to comment out the mention of __null in specstrings.h and pretend nobody will ever want it. Since since the mingw WinInet.h does not use it this is probably safe at least in the short term, if ugly. The other would be to say that this mingw uses a rather special gcc and will have x86_64 gcc patches, so pesuade gcc to use say __gnu_null for their version. That would be an easy patch to apply but probably politically difficult? I do not know a way to coax a preprocessor into avoiding re-scanning macroexpansions so one can have NULL => __null and __null => <nothing> both at once without NULL ending up as nothing. But if there was a preprocessor hack that could achive that it might fly. Arthur |
From: Kai T. <Kai...@on...> - 2007-09-28 08:09:42
|
SGkgQXJ0aHVyLA0KDQo+IE9uIFRodSwgMjcgU2VwIDIwMDcsIE5pZ2h0U3RyaWtlIHdyb3RlOg0K PiA+IE9uIDkvMjcvMDcsIEFydGh1ciBOb3JtYW4gPGFjbjFAY2FtLmFjLnVrPiB3cm90ZToNCj4g Pj4gc3RkZGVmLmggc2VlbXMgdG8gZ28NCj4gPj4gICAjZGVmaW5lIE5VTEwgX19udWxsDQo+ID4+ IHdoZW4geW91IGFyZSBpbiBDKysgbW9kZS4NCj4gPj4NCj4gPj4gc3BlY3N0cmluZ3MuaCBnb2Vz DQo+ID4+ICAgI2RlZmluZSBfX251bGwNCj4gPj4gYW5kIHRoYXQgaXMgaW5jbHVkZWQgYWxvbmcg d2l0aCBhIGxvYWQgb2Ygd2luZG93cyBoZWFkZXJzLg0KPiA+Pg0KPiA+PiBJZiBib3RoIG9mIHRo ZXNlIGFyZSB1c2VkIHRvZ2V0aGVyIE5VTEwgdHVybnMgaW50byBub3RoaW5nIGFuZCBtaXNlcnkN Cj4gPj4gcmVzdWx0cy4NCj4gPj4NCj4gPg0KPiA+IEFyZSB5b3Ugc3VnZ2VzdGluZyBzb21ldGhp bmcgaW52b2x2aW5nICNpZmRlZiBfX251bGw/DQo+ID4NCj4gSXQgbG9va3MgdG8gbWUgYXMgaWYg dGhlIGcrKyB3b3JsZCBhbmQg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