gnustep-dev
[Top][All Lists]
Advanced

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

corebase: use __builtin___CFStringMakeConstantString when available?


From: Daniel Ferreira (theiostream)
Subject: corebase: use __builtin___CFStringMakeConstantString when available?
Date: Tue, 27 Jun 2017 13:32:04 -0300

Hi,

I'm currently working on developing a CoreFoundation-based library
with CoreBase, and I just realized that unlike in OSX, CFSTR() does
not generate a compile-time CFStringRef constant.

This is fine compatibility-wise since CFSTR() does not guarantee that
it will do so -- in fact, Apple's own CoreFoundation headers check if
we are on Linux and if that is the case, it does not enable this
compile-time feature.

However, as far as my (extremely brief) investigation went we can
generate compile-time CFStringRefs using
__builtin___CFStringMakeConstantString(), which is present since this
gcc commit[1] and since forever in clang. So it makes sense to me that
this should not be platform-dependent, but rather compiler-dependent.

This helps because I need to export some CFStringRefs as symbols in a
new lib for WebKit compatibility, and without this feature I'd be left
with the option to either:
a) create an Objective-C file in a C-only library just for exporting NSStrings;
b) make a bizarre __attribute__((constructor))-like thing to
initialize the constant strings onto the symbols on library load.

Does this seem sane? If so, I need a tip in how to guard for this
builtin in gcc.

-- Daniel.

[1]: 
https://github.com/gcc-mirror/gcc/commit/d4238e8bcce578381de9480d78a651830a8f9754,
looks like it was added in gcc 5.3.



reply via email to

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