"Vesa Karvonen" <[EMAIL PROTECTED]> writes:

> 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, 

What are those, for us mortals, please?

> 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)).

A more useful (and I think easier) test for many purposes might be
empty or >0.

   #define CONFIG_MACRO 0

Is often a mental-model match for

   #undef CONFIG_MACRO

> 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.

I see.

-- 
                       David Abrahams
   [EMAIL PROTECTED] * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to