Hi, I suspect that this is a C++-specific error and relates to your host platform incorrectly defining NULL. In C, any pointer type can be cast to and from a `void*`, so you can cast `NULL` (typically defined as `(void*)0`) to an `id` or cast `nil` to a `void*` without issue. Unfortunately, in C++ this is not the case: `void*` is not special and so you need special handling. This is fixed in C++11 by providing `nullptr` as a language keyword: `nullptr` is a canonical null pointer that can be cast to any pointer type. C++ implementations are recommended to define `NULL` to `nullptr`, but not all do.
Apple appears to define `nil` as `nullptr` for C++. This will work, but it also allows incorrect code to compile: assigning `nil` to a non-object variable implies that whoever wrote the code assumes that the value is an object, when it isn’t. Masking this is probably a bad idea. David > On 1 Aug 2017, at 00:43, Daniel Ferreira (theiostream) <[email protected]> > wrote: > > Hi, > > In libobjc2, `nil` is defined as a null pointer cast to an `id`[1]. > However, this breaks a lot of stuff targeted to Apple's libobjc which > relies on `nil` and `NULL` being interchangeable. > > I've experimented removing that cast from the runtime.h header and > this works fine for compiling WebKit. This breaks libs-base and > libs-gui, though, with stuff like: > >> NSKeyedUnarchiver.m:862:33: error: cast to union type from type 'void *' not >> present in union >> GSIArrayAddItem(_objMap, (GSIArrayItem)nil); > > How do you suggest handling this issue? > > -- Daniel. > > [1]: https://github.com/gnustep/libobjc2/blob/master/objc/runtime.h#L207 > > _______________________________________________ > Gnustep-dev mailing list > [email protected] > https://lists.gnu.org/mailman/listinfo/gnustep-dev _______________________________________________ Gnustep-dev mailing list [email protected] https://lists.gnu.org/mailman/listinfo/gnustep-dev
