Boost logo

Boost Users :

From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2005-07-01 12:02:31


> -----Original Message-----
> From: boost-users-bounces_at_[hidden]
> [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Dave Steffen

> > How about adding a superfluous struct at the end of the function?
>
> > #define f(T) void my_func(T i) { do_sthg(); } struct
> semicolon_eater {}
>
> I haven't tried this yet, but it's the sort of thing I was
> fishing for. If the language says semicolons are illegal in
> certain places, but I want semicolons there (maybe for good
> reasons, maybe "just because, dammit!"), is there a clever
> construct that will let me get away with it?
>
> I'm gonna go try this (or something like it) soon, will report back.
> The advisability of doing this sort of thing is, perhaps,
> debatable; one of the reasons I wanted to push to GCC 3.4 is
> precisely this sort of thing: what are we doing that we shouldn't be?

As I'm sure you're aware of my opinion on this, so I won't repeat it.

If you going to do it anyway, then add a namespace somewhere...

namespace empty { };

...and then make the macro expansion end with:

using namespace ::empty

As in,

#define f() \
    void my_func() { do_something(); } \
    using namespace ::empty \
    /**/

f();

This shouldn't introduce any names into whatever scope you're in.

Regards,
Paul Mensonides


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net