Boost logo

Boost :

Subject: Re: [boost] Deprecation guidelines?
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2011-03-18 06:56:29


Paul A. Bristow wrote:
> > On Behalf Of John Maddock
> >
> > >> Where can one find guidelines on how to deprecate things
> > >> in Boost? What is the proper way to check that code
> > >> using Boost is clean?
> > >
> > > There is no standard for doing this. Right now, it's
> > > whatever each library author decides to do.
> >
> > If someone would like to volunteer to document best practice
> > on the Wiki though that would be great ;-)
>
> OK - I hope this might be within my skill set?
>
> Shall I start with a new thread asking for views?
>
> Or shall I dream up and post up a 'strawman' proposal for
> others to shoot at?

When it comes to marking functions as deprecated, here's what I know:

GCC: __attribute__((__deprecated__))
MSVC: __declspec(deprecated)

GCC allows the attribute to precede the return type or after the argument list. MSVC requires the declspec to precede the return type.

Therefore, I use a macro that is defined to one of the forgoing decorators, depending upon the compiler, and document that it must precede the return type for portability. It would be reasonable for the macro to take one parameter: the return type. It would then produce the decorator followed by the return type and force its use in the portable location. I haven't done that, but it is worth considering.

Therefore:

#if defined __GNUC__
# define BOOST_DEPRECATED(_return_type) \
   __attribute__((__deprecated__)) _return_type
#elif defined _MSC_VER
# define BOOST_DEPRECATED(_return_type) \
   __declspace(deprecated) _return_type
#endif

or just:

#if defined __GNUC__
# define BOOST_DEPRECATED __attribute__((__deprecated__))
#elif defined _MSC_VER
# define BOOST_DEPRECATED __declspace(deprecated)
#endif

_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer using std::disclaimer;
Dev Tools & Components
Susquehanna International Group, LLP http://www.sig.com

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk