how to mark macros as deprecated?

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

 



One can easily declare functions, variables and types as deprecated
by using the "deprecated" attribute, but what about macros?

In GNU MPFR's mpfr.h we have the following compatibility macros:

#define GMP_RNDN MPFR_RNDN
#define GMP_RNDZ MPFR_RNDZ
#define GMP_RNDU MPFR_RNDU
#define GMP_RNDD MPFR_RNDD

for old programs that are still using GMP_RNDx instead of the new
MPFR_RNDx, where the MPFR_RNDx values are defined in an enum. We
would like to have a warning emitted when GMP_RNDx is used.

I'm wondering what is possible to do.

Since MPFR_RNDx are defined by:

typedef enum {
  MPFR_RNDN=0,  /* round to nearest, with ties to even */
  MPFR_RNDZ,    /* round toward zero */
  MPFR_RNDU,    /* round toward +Inf */
  MPFR_RNDD,    /* round toward -Inf */
  MPFR_RNDA,    /* round away from zero */
  MPFR_RNDF,    /* faithful rounding (not implemented yet) */
  MPFR_RNDNA=-1 /* round to nearest, with ties away from zero (mpfr_round) */
} mpfr_rnd_t;

the following triggers a warning when a GMP_RNDx is used:

typedef int mpfr_gmp_rnd_t __attribute__
  ((deprecated ("GMP_RNDx is deprecated, use MPFR_RNDx instead")));

#define GMP_RNDN ((mpfr_rnd_t) (mpfr_gmp_rnd_t) MPFR_RNDN)
#define GMP_RNDZ ((mpfr_rnd_t) (mpfr_gmp_rnd_t) MPFR_RNDZ)
#define GMP_RNDU ((mpfr_rnd_t) (mpfr_gmp_rnd_t) MPFR_RNDU)
#define GMP_RNDD ((mpfr_rnd_t) (mpfr_gmp_rnd_t) MPFR_RNDD)

But could this have drawbacks or is there something more direct?

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux