* how to mark macros as deprecated?
@ 2014-02-24 9:40 Vincent Lefevre
0 siblings, 0 replies; only message in thread
From: Vincent Lefevre @ 2014-02-24 9:40 UTC (permalink / raw)
To: gcc-help
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@vinc17.net> - 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)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-02-24 9:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-24 9:40 how to mark macros as deprecated? Vincent Lefevre
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).