Boost logo

Boost :

From: Dave Steffen (dgsteffen_at_[hidden])
Date: 2005-11-11 10:59:56


Boris Burger writes:
> Hello,
> the issue with extra semicolons at namespace or class scope is
> surely nothing new and has been discussed extensively.

 Yes, I was one of the instigators...

> Still, I am not able to handle its incarnation in ptr_container
> sources, with G++ 3.4.5 (-ansi -pedantic). It goes like this:
>
> In ptr_map_adapter.hpp (and elsewhere), definition of class template
> ptr_map_adapter_base contains:
>
> BOOST_PTR_CONTAINER_DEFINE_CONSTRUCTORS(
> ptr_map_adapter_base, base_type );
>
> at class scope. G++ 3.4.5 reports the extra semicolon as
> an error (-ansi -pedantic warning level is rather strict here).

 ... because I was porting our code to GCC 3.4. (More accurately, I
 was porting our code to 3.4 with the errors and warnings turned all
 the way up.)

> Due to our company's policy lowering the warning levels is not an
> option. Patching the ptr_container classes would do the trick
> but that would require rather painful process of going through
> the Boost sources with each new version and removing extra
> semicolons.

 In fact, I don't think there's a way to lower warning levels to
 _just_ get rid of the semicolon complaints; you'd also be turning off
 warnings you want. The only solution I found was to either

          A) remove the semicolon, or
          B) to use a macro definition

 A) is easiest, but may make people's editors unhappy.

 B) involves something that is either clever, or a bletcherous hack,
 or both. I've found that things like:

   namespace empty_namespace_for_semicolons {
    void allow_semicolon(); }

#define ALLOW_SEMICOLON1 \
   typedef int semicolon_allowed_after_this_typedef

#define ALLOW_SEMICOLON2 \
 namespace only_for_semicolon=empty_namespace_for_semicolons

#define ALLOW_SEMICOLON3 \
  using empty_namespace_for_semicolons::allow_semicolon

 do the trick; these were suggested by people on this list. You'd then
 do something like

#define PTR_CONTAINER_DEFINE_CONSTRUCTORS(a,b) \
    BOOST_PTR_CONTAINER_DEFINE_CONSTRUCTORS(
          a,b ) ALLOW_SEMICOLON1

 And, finally, write your code like this:

  PTR_CONTAINER_DEFINE_CONSTRUCTORS(
      ptr_map_adapter_base, base_type );
  

 Clever? Or bletcherous hack? I think both. :-)
 

------------------------------------------------------------------------
Dave Steffen, Ph.D. On a paper submitted by a physicist colleague:
Software Engineer IV
Numerica Corporation "This isn't right. This isn't even wrong."
ph (970) 419-8343 x27
fax (970) 223-6797 -- Wolfgang Pauli
dgsteffen_at_[hidden]
______________________
Numerica Disclaimer:
This message and any attachments are intended only for the individual
or entity to which the message is addressed. It is proprietary and
may contain privileged information. If you are neither the intended
recipient nor the agent responsible for delivering the message to the
intended recipient, you are hereby notified that any review,
retransmission, dissemination, or taking of any action in reliance
upon, the information in this communication is strictly prohibited,
and may be unlawful. If you feel you have received this communication
in error, please notify us immediately by returning this Email to the
sender and deleting it from your computer.


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