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: Daniel Ferreira (theiostream)
Subject: Re: error compiling GUI - string constants
Date: Wed, 26 Jul 2017 08:37:27 -0300

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. 

On Jul 26, 2017 07:35, "Riccardo Mottola" <address@hidden> wrote:
Hi,

while compiling GUI, I get these errors abount string constants.

 Compiling file externs.m ...
externs.m:270:1: error: initializer element is not constant
 NSString *const NSStringPboardType = NSPasteboardTypeString;
 ^
externs.m:273:1: error: initializer element is not constant
 NSString *const NSColorPboardType = NSPasteboardTypeColor;
 ^
externs.m:276:1: error: initializer element is not constant
 NSString *const NSFontPboardType = NSPasteboardTypeFont;
 ^
externs.m:279:1: error: initializer element is not constant
 NSString *const NSRulerPboardType = NSPasteboardTypeRuler;
 ^
externs.m:282:1: error: initializer element is not constant
 NSString *const NSTabularTextPboardType = NSPasteboardTypeTabularText;

<...>


What is the issue? I see the definition here:
Headers/AppKit/NSPasteboard.h:APPKIT_EXPORT NSString *const NSPasteboardTypeString;
Source/externs.m:NSString *const NSPasteboardTypeString = @"NSStringPboardType";

and it is declared as *const.

NSString *const is not "constant" to initialize a definition (I tried "const NSString *const" too but it doesn't work: constant string to a constant pointer)

The only working way I found is not to use the previous string delcaration in the next one, e.g.:

NSString *const NSPasteboardTypeString = @"NSStringPboardType";
NSString *const NSStringPboardType = @"NSStringPboardType";

instead of
NSString *const NSStringPboardType = NSPasteboardTypeString;

thins fixes my compilation issue, but I am hesitating to commit this since it looks "stupid" to me

What is GCC doing here or what I am overlooking?

Riccardo


_______________________________________________
Gnustep-dev mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/gnustep-dev

reply via email to

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