Boost logo

Boost :

From: Vesa Karvonen (vesa_karvonen_at_[hidden])
Date: 2003-01-05 12:39:31


David Abrahams:
>Vesa Karvonen:
> > to the Boost Preprocessor library to help detect whether flag like
> > macros are defined. These macros would make it easier to move some
> > logic from unusable #if blocks into usable macros.

>Can you show an example of such a transformation?

I got this idea while reading the following thread on the comp.programming
newsgroup:
http://groups.google.com/groups?dq=&hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=Xns92FA369D1BE1newspubwuggyorg%40217.32.252.50&prev=/groups%3Fq%3Dcomp.programming%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den

I thought about suggesting use of macros (with help from
Boost.Preprocessor), which would allow using code like this:

  #pragma SECTION(RXFILTERS_C,rxdata,ADC_output)
  // ...

While writing the answer, I got bored writing the "BOOL" versions of the
macros, so I started thinking about how to detect whether a macro was
defined. The BOOST_PP_IS_EMPTY(), etc... macros that I came up with are not
a complete replacement for defined(), but they can help (especially in
probably the most common case when a macro simply serves as a flag and is
defined to be either empty or 1 (this excludes __cplusplus and many other
compiler defined flags in the general case, btw)).

I think that repeating #if blocks, often using defined(), could be extracted
from quite a few programs written in C or C++ that have been ported to
multiple platforms. I don't have more specific examples in mind, however.

-Vesa Karvonen

_________________________________________________________________
MSN 8: advanced junk mail protection and 2 months FREE*.
http://join.msn.com/?page=features/junkmail


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