>>> Please simplify the above to (untested):
>>> 
>>> #elif defined (__APPLE__)
>>>       /* By default, macOS volumes are case-insensitive, iOS
>>>          volumes are case-sensitive.  */
>>> #if TARGET_OS_MAC    /* macOS, in older SDK.  */
>>>        file_names_case_sensitive_cache = 0;
>>> #elif TARGET_OS_OSX  /* macOS, in recent SDK.  */
>>>        file_names_case_sensitive_cache = 0;
>>> #else                /* assume iOS.  */
>>>        file_names_case_sensitive_cache = 1;
>>> #endif
>>> #else /* Neither Windows nor Apple.  */
>>>      file_names_case_sensitive_cache = 1;
>>> #endif
>>> 
>>> which is simpler and more readable and should be equivalent AFAICT.
>>> 
>>> OK with the above change.
>>> 
>>> Arno
>> 
>> Sorry, but that wouldn’t work.
> 
> Then invert the two first tests, that doesn't change the gist of my 
> suggestion to simplify the
> tests.

Apple’s naming is definitely confusing in this area!

In current SDKs, TARGET_OS_MAC means code is being generated for a Mac OS X 
variant, 
which covers OSX, IOS, Watch … ; to determine which kind of device, you have to 
check the 
specific define for that device - OSX corresponds to macOS, i.e. laptops, 
desktops.

In older SDKs (specifically Xcode 3, for macOS Leopard (darwin 9) as mentioned 
by Iain) 
TARGET_OS_MAC means code is being generated for "Mac OS", i.e. laptops, 
desktops as 
above; TARGET_OS_OSX is undefined (as are TARGET_OS_IOS etc).

If we are compiling for macOS, using a current macOS SDK, then TARGET_OS_MAC is
set to 1 and TARGET_OS_OSX is set to 1. 

If we were compiling for iOS, using a current iOS SDK as supplied with current 
Xcode, then 
TARGET_OS_MAC would be set to 1, TARGET_OS_OSX would be set to 0, and 
TARGET_OS_IOS would be set to 1.

If TARGET_OS_OSX is defined then
        —  we’re generating code for a recent Apple device, TARGET_OS_MAC could 
mean 
        —  macOS, iOS, iWatch etc, so we can’t use it.
        if TARGET_OS_OSX is 1 then
                —  we’re generating code for macOS, file names are 
case-insensitive.
        else
                —  we’re trying to generate code for a device which GCC doesn’t 
support at 
                —  the moment, e.g. iOS; let’s  assume file names are 
case-sensitive..
        end if
else
        if TARGET_OS_MAC is 1 then
                —  we’re generating code for macOS, file names are 
case-insensitve.
        else
                —  let’s assume file names are case-sensitive.
        end if
end if

What we’re doing here is providing a default behaviour; it’s certainly the case 
that Apple filesystems are by default case-insensitive. If a user has code on 
case-sensitive file systems (Apple or other, e.g. unix-over-NFS) it’s up to 
them to use GNAT_FILE_NAME_CASE_SENSITIVE.

>> TargetConditionals.h is created by Apple as part of SDK construction, so the 
>> TARGET_* macros are defined directly (#define TARGET_OS_OSX 1),
>> 
>> In a newer macOS SDK, both TARGET_OS_MAC and TARGET_OS_OSX are defined and 
>> set to 1, and TARGET_OS_MAC covers OSX (macOS), IOS, TV, WATCH and others.
>> In an older macOS SDK, TARGET_OS_MAC is defined and set to 1, and none of 
>> the others are defined at all.

Reply via email to