gnustep-dev
[Top][All Lists]
Advanced

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

Re: error compiling GUI - string constants


From: David Chisnall
Subject: Re: error compiling GUI - string constants
Date: Fri, 28 Jul 2017 10:26:53 +0100

On 27 Jul 2017, at 17:06, Fred Kiefer <address@hidden> wrote:
> 
>> 
>> Am 27.07.2017 um 10:26 schrieb David Chisnall <address@hidden>:
>> 
>> On 26 Jul 2017, at 14:58, Josh Freeman <address@hidden> wrote:
>>> 
>>> On Jul 26, 2017, at 7:37 AM, Daniel Ferreira (theiostream) wrote:
>>> 
>>>> Also, the reason it just does not assign the same const string to the 
>>>> different constants is because the two consts should be the same pointer, 
>>>> and doing it explicitly seemed like a good way to make that intent clear 
>>>> and guarantee that would happen.
>>> 
>>> 
>>> Changing the second string constant into a macro of the first would 
>>> guarantee they're the same pointer:
>>> 
>>> APPKIT_EXPORT NSString *NSStringPboardType;
>>> 
>>> ...
>>> 
>>> #if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
>>> #    define NSPasteboardTypeString NSStringPboardType
>>> #endif
>> 
>> Am I missing something?  Why not simply make the first symbol an alias for 
>> the second?
> 
> 
> David, what do you mean by alias?

I thought that GCC had an attribute for it, but apparently not.  The following 
works on ELF platforms, at least, and there are equivalents for Mach-O:

        #include <stdio.h>
        int x;

        extern int y;
        asm (".weakref y, x");

        int main(void)
        {
                y = 0;
                x = 42;
                // Prints 42
                printf(“%d\n”, y);
        }

So this would work for our use:

        extern NSPasteboardTypeString;
        asm(".weakref NSPasteboardTypeString NSStringPboardType");

We’d end up in the linked binary with a single location with two symbol names.  

David




reply via email to

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