This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: #import and PCH


> As long as the official Foundation docs use #import, I'd say removing  
> #import for Objective C, or enforcing warnings for it, is not justifiable.
> 
> That doesn't necessarily mean that it cannot be deprecated for all other  
> languages; AFAICT there is no such justification for those.
> 
> What *could* be done is (in FSF GCC) eliminate or deprecate the use-once  
> effect, turning #import into an alias for #include and telling users to  
> fix their headers if that doesn't work.

Kai, I vote for your suggestion.

We could change FSF GCC so that #import is just an alias for #include.

Then

 - FSF GCC code is completely free from any multiple-include-files hack;

 - ObjC code properly written, using #import to include system headers,
and protecting its own headers against multiple inclusions, will be
perfectly portable, and compile and run and be usable on both Apple Mac OS
X and GNUstep.

I know this means any code ported from Apple to GNU which doesn't protect
its headers against multiple inclusions will require them to be modified
to protect them against multiple inclusions, and that is not extremely
friendly for Apple programmers.

I also know that this means that #import will not behave in FSF GCC as
described in Apple ObjC documentation.  

But given the arrogant, pushy and wall-against-wall approach that Apple
has on the matter (they on purpose keep #include <Foundation/NSObject.h>
broken on their systems to force you to use #import), I don't see any
space for mediation with them on this matter.

We all agree that the protect-against-multiple-inclusion `feature' of
#import is horrible and costing us too much time and effort - so maybe
removing it is not a bad idea, while keeping #import as an alias to
#include to allow portable programs be written.

All this stuff should of course be very well documented - with careful
explanations of why the protect-against-multiple-inclusion `feature' of
#import has been removed, to prevent users from barfing too much when they
find that out.


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