discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting xcodeproj to makefile


From: Richard Frith-Macdonald
Subject: Re: Converting xcodeproj to makefile
Date: Wed, 19 Sep 2012 12:08:36 +0100

On 19 Sep 2012, at 10:38, pepijn de vos wrote:

> Uhm, okay. I'm not sure I understand what you mean. The header file defines 
> only protocols and interfaces for existing classes.

On some (most?) operating systems, when the operating system starts a program 
executing, it pulls in only those bits of dynamic library code that it thinks 
the program needs.

The essence of the process is that it looks at the program executable for 
references to things that aren;t inside the program, natches those references 
with things that are defined in the dynamic libraries, and pulls in the 
matching library code.

If you have a file that contains nothing but categories and protocols, then 
most likely nothing in your program will reference anything in that file ... so 
the operating system won't include that file when you run your program ... so  
the reason your categories aren't being used is that they aren't in your 
program!  On MacOS, Apple have set up the operating system so that it *does* 
load in the categories even when nothing references them, so things work there 
'magiaclly' :-)

The workaround is to do something like:

1. Define an external variable in the file containing the category code.
eg.
int categoryLinkLoadHack = 1;

2. Reference that variable in your program

> I added this test that checks if the class of NSDictionary is the class of an 
> instance of NSDictionary, and specified for all NSDictionaries that they 
> implement BSONCoding.
> 
> https://github.com/pepijndevos/bson-objc/blob/master/gnutest/gnutest.m#L8
> 
> The surprising result, on Mac(which works fine):
> Failed test:       gnutest.m:9 ... NSDictionary is an NSDictionary.
> 
> On Linux:
> Failed set:        gnutest.m:13 ... problem in Array.
> Failed set:        gnutest.m:119 ... problem in Null.
> Failed set:        gnutest.m:142 ... problem in Number.

This is not surprising if your categories are simply not being used.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]