Boost logo

Boost :

From: Paul Hamilton (paul_at_[hidden])
Date: 2003-08-18 12:04:33


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 {

   template<class Tr, class Ch> inline
   void empty_buf(BOOST_IO_STD basic_ostringstream<Ch,Tr> & os) {
     static const std::basic_string<Ch, 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
   template<class Tr, class Ch> inline
   void empty_buf(BOOST_IO_STD basic_ostringstream<Ch,Tr> & os) {
     extern const std::basic_string<Ch, 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:paul_at_[hidden]

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


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