This piece of code is from SubtitleKit, a library regarding processing different types of subtitle files. I occasionally use some features that does not exist in GCC or older versions of Clang so I used those boilerplates to make sure my code compiles under all my target platforms with minimal changes. My targets include OS X 10.7-10.9, iOS 5-7 and GNUstep SVN.
Sent from my iPhone > On 2013年6月14日, at 16:24, Ivan Vučica <[email protected]> wrote: > > I never needed something like what you wrote. That stuff belongs in a > framework. If a compiler doesn't support an attribute that I need (and I > typically don't need attributes), then I don't support the compiler. > > Objective-C modules also doesn't really need anything special to expose C > functions to modules written in C, except perhaps an extern "C" in case a > header defining C functions is included by a C++ module. > > So no, I don't typically have things like what you wrote down there :-) > > Regards, > > Ivan Vučica > via phone > >> On 14. 6. 2013., at 08:58, Maxthon Chan <[email protected]> wrote: >> >> I mean exposing a function or two from Objective-C code so that it can be >> accessed from other languages. There is no reason to prevent a function with >> signature CGIApplicationMain(int, const char **, const char *restrict, const >> char *restrict); from being exposed, right? >> >> Also, the inline function wrapper for [NSString stringWithFormat:] can be >> really useful. >> >> Sent from my iPhone >> >>> On 2013年6月14日, at 14:21, Jamie Ramone <[email protected]> wrote: >>> >>> Why...would anyone want to do that? The whole point of OOP is to hide >>> details so as to allow programmers to concentrate on one thing at a time >>> (while giving us the bonus of modular, reusable, easily maintainable code). >>> Why would you want/need to unhide details? >>> >>> >>>> On Fri, Jun 14, 2013 at 2:59 AM, Maxthon Chan <[email protected]> wrote: >>>> Copied from Xcode and Mail saved all formatting from code highlighting as >>>> RTF. The code boilerplate is what I always use as a start point of my >>>> code. It makes it possible to expose some Objective-C code as plain C/C++ >>>> as I did in CGIKit 5, and it detects compiler. I have a newer version that >>>> does easy string constant too. >>>> >>>> Sent from my iPhone >>>> >>>>> On 2013年6月14日, at 13:51, Jamie Ramone <[email protected]> wrote: >>>>> >>>>> Colorful text is colorful! So what is this "boilerplate" thing exactly? >>>>> I've heard the expression before but not quite sure what it refers to. >>>>> >>>>> >>>>>> On Wed, Jun 12, 2013 at 12:25 PM, Maxthon Chan <[email protected]> wrote: >>>>>> Do you guys have a boilerplate that you are very used to build code on >>>>>> top of? I have one like this (sans include guard which depend on header >>>>>> file name): >>>>>> >>>>>> #include <sys/cdefs.h> >>>>>> #include <stdarg.h> >>>>>> #include <stdint.h> >>>>>> #include <stddef.h> >>>>>> #include <sys/types.h> >>>>>> >>>>>> // Feature testers >>>>>> >>>>>> #ifndef __has_feature >>>>>> #define __has_feature(x) 0 >>>>>> #endif >>>>>> >>>>>> #ifndef __has_builtin >>>>>> #define __has_builtin(x) 0 >>>>>> #endif >>>>>> >>>>>> #ifndef __has_extension >>>>>> #define __has_extension(x) 0 >>>>>> #endif >>>>>> >>>>>> #ifndef __has_attribute >>>>>> #define __has_attribute(x) 0 >>>>>> #endif >>>>>> >>>>>> // __inline >>>>>> >>>>>> #if __has_attribute(always_inline) >>>>>> #define __inline static inline __attribute__((always_inline)) >>>>>> #else // !__has_attribute(always_inline) >>>>>> #define __inline static inline >>>>>> #endif// __has_attribute(always_inline) >>>>>> >>>>>> // __restrict >>>>>> >>>>>> #ifndef __cplusplus >>>>>> #ifndef __restrict >>>>>> #if __STDC_VERSION__ >= 199901L >>>>>> #define __restrict restrict >>>>>> #else // __STDC_VERSION__ < 199901L >>>>>> #define __restrict >>>>>> #endif // __STDC_VERSION__ >= 199901L >>>>>> #endif // !defined(__restrict) >>>>>> #endif // !defined(__cplusplus) >>>>>> >>>>>> // noreturn (__noreturn and unreachable()) >>>>>> >>>>>> #if __has_attribute(noreturn) >>>>>> #define __noreturn __attribute__((noreturn)) >>>>>> #if __has_builtin(__builtin_unreachable) >>>>>> #define unreachable() __builtin_unreachable() >>>>>> #else // !__has_builtin(__builtin_unreachable) >>>>>> #define unreachable() do {} while (0) >>>>>> #endif // __has_builtin(unreachable) >>>>>> #else // !__has_attribute(noreturn) >>>>>> #define __noreturn >>>>>> #define unreachable() do {} while (0) >>>>>> #endif // __has_attribute(noreturn) >>>>>> >>>>>> // Deprecated/unavalible with messages >>>>>> >>>>>> #undef __deprecated >>>>>> #undef __unavailable >>>>>> >>>>>> #if __has_attribute(deprecated) >>>>>> #if __has_extension(attribute_deprecated_with_message) >>>>>> #define __deprecated(_msg) __attribute__((deprecated(_msg))) >>>>>> #else // !__has_extension(attribute_deprecated_with_message) >>>>>> #define __deprecated(_msg) __attribute__((deprecated)) >>>>>> #endif // __has_extension(attribute_deprecated_with_message) >>>>>> #else // !__has_attribute(deprecated) >>>>>> #define __deprecated(_msg) >>>>>> #endif // __has_attribute(deprecated) >>>>>> >>>>>> #if __has_attribute(unavailable) >>>>>> #if __has_extension(attribute_unavailable_with_message) >>>>>> #define __unavailable(_msg) __attribute__((unavailable(_msg))) >>>>>> #else // !__has_extension(attribute_unavailable_with_message) >>>>>> #define __unavailable(_msg) __attribute__((unavailable)) >>>>>> #endif // __has_extension(attribute_unavailable_with_message) >>>>>> #else // !__has_attribute(unavailable) >>>>>> #define __unavailable(_msg) >>>>>> #endif // __has_attribute(unavailable) >>>>>> >>>>>> #if __has_extension(enumerator_attributes) >>>>>> #define __e_deprecated(_msg) __deprecated(_msg) >>>>>> #define __e_unavailable(_msg) __unavailable(_msg) >>>>>> #else // !__has_extension(enumerator_attributes) >>>>>> #define __e_deprecated(_msg) >>>>>> #define __e_unavailable(_msg) >>>>>> #endif // __has_extension(enumerator_attributes) >>>>>> >>>>>> // Format strings >>>>>> >>>>>> #if __has_attribute(format) >>>>>> #define __format(...) __attribute__((format(__VA_ARGS__))) >>>>>> #else // __has_attribute(format) >>>>>> #define __format(...) >> _______________________________________________ >> Gnustep-dev mailing list >> [email protected] >> https://lists.gnu.org/mailman/listinfo/gnustep-dev
_______________________________________________ Gnustep-dev mailing list [email protected] https://lists.gnu.org/mailman/listinfo/gnustep-dev
