diff --git a/ChangeLog b/ChangeLog index 2c82e1025..5c204ee90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2013-12-30 Marcus Mueller + + * Headers/GNUstepBase/GSVersionMacros.h: added macros + GS_GCC_MINREQ(maj,min) and GS_CLANG_MINREQ(maj,min) to check for + minimum required versions of GCC and CLANG compilers. Changed several + occurrences of previous macros to improve readability. + Added GS_PROTOCOLS_HAVE_OPTIONAL to correctly mark all appropriate + declarations. + * Headers/Foundation/NSNetServices.h, + * Headers/Foundation/NSStream.h, + * Headers/Foundation/NSXMLParser.h, + * Headers/GNUstepBase/NSNetServices+GNUstepBase.h, + * Source/GSNetServices.h: + use GS_PROTOCOLS_HAVE_OPTIONAL macro where appropriate + 2013-12-26 Marcus Mueller * Headers/Foundation/NSNetServices.h: diff --git a/Headers/Foundation/NSNetServices.h b/Headers/Foundation/NSNetServices.h index 46934c05d..33612d3f4 100644 --- a/Headers/Foundation/NSNetServices.h +++ b/Headers/Foundation/NSNetServices.h @@ -114,7 +114,7 @@ GS_EXPORT NSString * const NSNetServicesErrorDomain; @protocol NSNetServiceDelegate -#ifdef __clang__ /* FIXME ... this is not clang specific */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6,GS_API_LATEST) && GS_PROTOCOLS_HAVE_OPTIONAL @optional #else @end @@ -243,7 +243,7 @@ GS_EXPORT NSString * const NSNetServicesErrorDomain; */ @protocol NSNetServiceBrowserDelegate -#ifdef __clang__ /* FIXME ... this is not clang specific */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6,GS_API_LATEST) && GS_PROTOCOLS_HAVE_OPTIONAL @optional #else @end diff --git a/Headers/Foundation/NSStream.h b/Headers/Foundation/NSStream.h index 5af2fa27a..292e1c598 100644 --- a/Headers/Foundation/NSStream.h +++ b/Headers/Foundation/NSStream.h @@ -270,8 +270,7 @@ GS_EXPORT NSString * const NSStreamSOCKSProxyVersion4; GS_EXPORT NSString * const NSStreamSOCKSProxyVersion5; GS_EXPORT NSString * const NSStreamSOCKSProxyVersionKey; -#if OS_API_VERSION(MAC_OS_X_VERSION_10_7,GS_API_LATEST) && defined(__clang__) -/* FIXME ... this is not clang specific */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_7,GS_API_LATEST) && GS_PROTOCOLS_HAVE_OPTIONAL @protocol NSStreamDelegate @optional #else diff --git a/Headers/Foundation/NSXMLParser.h b/Headers/Foundation/NSXMLParser.h index df862a75d..c8e01d51b 100644 --- a/Headers/Foundation/NSXMLParser.h +++ b/Headers/Foundation/NSXMLParser.h @@ -190,7 +190,7 @@ GS_EXPORT NSString* const NSXMLParserErrorDomain; * This is now a formal protocol. */ @protocol NSXMLParserDelegate -#ifdef __clang__ /* FIXME ... this is not clang specific */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6,GS_API_LATEST) && GS_PROTOCOLS_HAVE_OPTIONAL @optional #else @end diff --git a/Headers/GNUstepBase/GSVersionMacros.h b/Headers/GNUstepBase/GSVersionMacros.h index 27cc99d4e..374d015b8 100644 --- a/Headers/GNUstepBase/GSVersionMacros.h +++ b/Headers/GNUstepBase/GSVersionMacros.h @@ -220,6 +220,20 @@ #endif +#if defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__clang__) +# define GS_GCC_MINREQ(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +#else +# define GS_GCC_MINREQ(maj, min) 0 +#endif + +#if defined(__clang__) +# define GS_CLANG_MINREQ(maj, min) \ + ((__clang_major__ << 16) + __clang_minor__ >= ((maj) << 16) + (min)) +#else +# define GS_CLANG_MINREQ(maj, min) 0 +#endif + /* Attribute definitions for attributes which may or may not be supported * depending on the compiler being used. * NB we currently expect gcc to be version 4 or later. @@ -229,7 +243,7 @@ * depending on where the attribute can be applied. */ -#if __GNUC__*10+__GNUC_MINOR__ >= 31 +#if defined(__clang__) || GS_GCC_MINREQ(3,1) # define GS_DEPRECATED_FUNC __attribute__ ((deprecated)) #else # define GS_DEPRECATED_FUNC @@ -392,7 +406,7 @@ static inline void gs_consumed(id NS_CONSUMED GS_UNUSED_ARG o) { return; } /* Attribute macros compatible with Apple. */ -#if __GNUC__*10+__GNUC_MINOR__ >= 42 +#if defined(__clang__) || GS_GCC_MINREQ(4,2) # define NS_FORMAT_ARGUMENT(A) __attribute__((format_arg(A))) #else # define NS_FORMAT_ARGUMENT(F,A) @@ -407,5 +421,12 @@ static inline void gs_consumed(id NS_CONSUMED GS_UNUSED_ARG o) { return; } #define NS_REQUIRES_NIL_TERMINATION __attribute__((sentinel)) +/* Check if compiler supports @optional in protocols + */ +#if defined(__clang__) || GS_GCC_MINREQ(4,6) +# define GS_PROTOCOLS_HAVE_OPTIONAL 1 +#else +# define GS_PROTOCOLS_HAVE_OPTIONAL 0 +#endif #endif /* __GNUSTEP_GSVERSIONMACROS_H_INCLUDED_ */ diff --git a/Headers/GNUstepBase/NSNetServices+GNUstepBase.h b/Headers/GNUstepBase/NSNetServices+GNUstepBase.h index 2f1820386..2a642d95c 100644 --- a/Headers/GNUstepBase/NSNetServices+GNUstepBase.h +++ b/Headers/GNUstepBase/NSNetServices+GNUstepBase.h @@ -81,12 +81,12 @@ @protocol GSNetServiceDelegate -#ifdef __clang__ +#if GS_PROTOCOLS_HAVE_OPTIONAL @optional #else @end @interface NSObject (GSNetServiceDelegateMethods) -#endif // __clang__ +#endif // GS_PROTOCOLS_HAVE_OPTIONAL /** * Notifies the delegate that the addresses for the service have diff --git a/Source/GSNetServices.h b/Source/GSNetServices.h index cdf748fb7..93a78c0df 100644 --- a/Source/GSNetServices.h +++ b/Source/GSNetServices.h @@ -74,11 +74,7 @@ NSString* GSNetServiceDotTerminatedNSStringFromString(const char* string); /** * NSNetService using the avahi-client API. */ -#ifdef __clang__ /* FIXME ... this is not clang specific! */ @interface GSAvahiNetService : NSNetService -#else -@interface GSAvahiNetService : NSNetService -#endif { // GSAvahiClient behaviour ivars: // From superclass: id _delegate; @@ -120,12 +116,8 @@ NSString* GSNetServiceDotTerminatedNSStringFromString(const char* string); /** * NSNetServiceBrowser using the avahi-client API. */ -#ifdef __clang__ /* FIXME ... this is not clang specific! */ @interface GSAvahiNetServiceBrowser : NSNetServiceBrowser -#else -@interface GSAvahiNetServiceBrowser: NSNetServiceBrowser -#endif { // GSAvahiClient behaviour ivars: // from superclass: id _delegate; @@ -147,21 +139,13 @@ NSString* GSNetServiceDotTerminatedNSStringFromString(const char* string); /** * NSNetService using the mDNSResponder API. */ -#ifdef __clang__ /* FIXME ... this is not clang specific! */ @interface GSMDNSNetService : NSNetService -#else -@interface GSMDNSNetService : NSNetService -#endif @end /** * NSNetServiceBrowser using the mDNSResponder API. */ -#ifdef __clang__ /* FIXME ... this is not clang specific! */ @interface GSMDNSNetServiceBrowser : NSNetServiceBrowser -#else -@interface GSMDNSNetServiceBrowser : NSNetServiceBrowser -#endif @end #endif // GS_USE_AVAHI