#import, #pragma once yadda yadda mumble grumble

Devang Patel dpatel@apple.com
Wed Jul 30 17:22:00 GMT 2003


On Tuesday, July 29, 2003, at 10:23 PM, Neil Booth wrote:

>
>>> 2) What happens if you mix #include and #import of the same file?
>>
>> Nothing in particular; #import behavior is only affected by previous 
>> #import
>> directives, not by #include, and #include ignores any previous 
>> #import's.
>
> Yes.

Your patch changes semantics for following example.

	#include "a.h"
	#import "a.h"
	#include "a.h"

And a.h does not have include guards.

FSF GCC 3.4 before and after your patch behaves differently.

*If* we consider Darwin compilers as reference in this case then 
following
compiler versions include content of a.h only once in this example.
- Darwin GCC 2.95 + Apple preprocessor
- Darwin GCC 2.95 + GNU preprocessor
- Darwin GCC 3.1 + Apple preprocessor
- Darwin GCC 3.1 + GNU preprocessor
- Darwin GCC 3.3

--
Devang



More information about the Gcc mailing list