libtom / libtommath

LibTomMath is a free open source portable number theoretic multiple-precision integer library written entirely in C.
https://www.libtom.net
Other
650 stars 194 forks source link

gcc + __attribute__((deprecated)) #322

Closed karel-m closed 5 years ago

karel-m commented 5 years ago

Building with gcc-3.4.5 fails with error:

tommath.h:234: error: wrong number of arguments specified for `deprecated' attribute

It looks like gcc 3.x does support:

__attribute__((deprecated))

but not:

__attribute__((deprecated("some message")))
karel-m commented 5 years ago

IMO __attribute__((deprecated("some message"))) is supported since gcc-4.5.0 see:

So perhaps:

- #if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 301)
+ #if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 405)
karel-m commented 5 years ago

Or more complicated:

- #if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 301)
+ #if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 405)
  #  define MP_DEPRECATED(x) __attribute__((deprecated("replaced by " #x)))
  #  define PRIVATE_MP_DEPRECATED_PRAGMA(s) _Pragma(#s)
  #  define MP_DEPRECATED_PRAGMA(s) PRIVATE_MP_DEPRECATED_PRAGMA(GCC warning s)
+ #elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 301)
+ #  define MP_DEPRECATED(x) __attribute__((deprecated))
+ #  define PRIVATE_MP_DEPRECATED_PRAGMA(s) _Pragma(#s)
+ #  define MP_DEPRECATED_PRAGMA(s) PRIVATE_MP_DEPRECATED_PRAGMA(GCC warning s)
  #elif defined(_MSC_VER) && _MSC_VER >= 1500
  #  define MP_DEPRECATED(x) __declspec(deprecated("replaced by " #x))
  #  define MP_DEPRECATED_PRAGMA(s) __pragma(message(s))
  #else
  #  define MP_DEPRECATED(s)
  #  define MP_DEPRECATED_PRAGMA(s)
  #endif
minad commented 5 years ago

@karel-m This has been fixed in https://github.com/libtom/libtommath/pull/262/commits/1eceaeaad2cf1df708b07da3818a3ddbdd39ef05 in #262

karel-m commented 5 years ago

The #262 is not correct

minad commented 5 years ago

@karel-m What do you mean? Is not correct? #262 has not been merged yet, do you mean that?

karel-m commented 5 years ago

#if defined(__GNUC__) && __GNUC__ >= 4 is wrong and will cause a failure with e,g, gcc-4.4 see my research above.

minad commented 5 years ago

@karel-m Thank you. Fixed in #262

karel-m commented 5 years ago

Great, closing this one.