[boost] Global vars

2003-08-18 Thread Paul Hamilton
Well,

I've tried to work through the solutions to:

ld: common symbols not allowed with MH_DYLIB output format

Which are basically -fno-common on the compile line of each file, but 
apart from the fact that tihs doesn't actually work in this case (we 
still get the error), it's not really a very good idea.

Does anybody have any suggestions for working around this code:

namespace boost {
namespace io {
namespace detail {
namespace  {
  templateclass Tr, class Ch inline
  void empty_buf(BOOST_IO_STD basic_ostringstreamCh,Tr  os) {
static const std::basic_stringCh, Tr emptyStr;
os.str(emptyStr);
  }
};};};};

The correct thing to do with this code (for all platforms) is to not 
rely on the global variable common stuff (which is new to me, and 
seems a bit of a hack), but actually do this code correctly, which 
means removing the global variable.

What problem is the code above trying to solve?

If i just do this (which i have done to get my stuff working), there 
seems to be no prob:

#ifdef MACHACK
  templateclass Tr, class Ch inline
  void empty_buf(BOOST_IO_STD basic_ostringstreamCh,Tr  os) {
extern const std::basic_stringCh, Tr emptyStr;
os.str(emptyStr);
  }
#else
#define empty_buf(_os_) (_os_).str();
#endif
Wouldn't the above two lines achieve basically the same thing (although 
I know we hate macros, but since empty_buf is only actually used 3 
times in the entire project, could all of the:

	empty_buf(oss);

be replaced with:

	oss.str();

This would save a whole lot of grief and eliminate this fairly ugly 
global variable.

Comments?

-
Paul Hamilton
pHamtec P/L - Software Makers
http://www.phamtec.com/
mailto:[EMAIL PROTECTED]
The information transmitted is intended only for the person or entity 
to which it is addressed and may contain confidential and/or privileged 
material. Any review, retransmission, dissemination or other use of, or 
taking of any action in reliance upon, this information by persons or 
entities other than the intended recipient is prohibited. If you 
received this in error, please contact the sender and delete the 
material from any computer.
-

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


Re: [boost] Global vars

2003-08-18 Thread Peter Dimov
Paul Hamilton wrote:
 Well,
 
 I've tried to work through the solutions to:
 
 ld: common symbols not allowed with MH_DYLIB output format
 
 Which are basically -fno-common on the compile line of each file, but 
 apart from the fact that tihs doesn't actually work in this case (we
 still get the error), it's not really a very good idea.
 
 Does anybody have any suggestions for working around this code:
 
 namespace boost {
 namespace io {
 namespace detail {
 namespace  {
 
templateclass Tr, class Ch inline
void empty_buf(BOOST_IO_STD basic_ostringstreamCh,Tr  os) {
  static const std::basic_stringCh, Tr emptyStr;
  os.str(emptyStr);
}
 
 };};};};

Did you try to remove the static const?
___
Unsubscribe  other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Re: [boost] Global vars

2003-08-18 Thread Paul Hamilton
Peter Dimov wrote:

Did you try to remove the static const?
Not sure if this would achieve the same effect as the code is trying to 
get done. I think it's a static const so that the the compiler will 
optimize it out and just init the string.

Paul.

-
Paul Hamilton
pHamtec P/L - Software Makers
http://www.phamtec.com/
mailto:[EMAIL PROTECTED]
The information transmitted is intended only for the person or entity 
to which it is addressed and may contain confidential and/or privileged 
material. Any review, retransmission, dissemination or other use of, or 
taking of any action in reliance upon, this information by persons or 
entities other than the intended recipient is prohibited. If you 
received this in error, please contact the sender and delete the 
material from any computer.
-

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