Date: 2000-12-18 10:14:10
> Indeed, if a compiler came out that actually had problems with assert
> (), I claim that that compiler could not be successful, based on the
> widespread use of assert().
The problem only occurs when assert() is used in header files. There are no
ODR problems with assert() in non-included files.
> Another point -- boost is full of ODR violations! Any inline or
> template code that is conditioned on some compile-time variable
> violates the ODR, doesn't it?
No. Different template parameter values -> different (mangled) symbol names
-> no ODR problems.
ODR problems surface when code in header files is different based on
preprocessor symbols that are not equivalent across all translation units.
There are several ways around this:
. Make code dependent on template parameters instead of preprocessor
symbols; this makes for messy user code. :(
. Suggest a "restriction" that all preprocessor symbols are the same
across all translation units. The problem is that there's no way to enforce
. Place all code that is dependent on changeable preprocessor symbols
(meaning NDEBUG, not __WIN32__) in a non-included file, and have two Boost
libraries: debug and release. This may discourage the compiler from
. Try to get the unnamed namespace thing working. I haven't had the time
to look at this and see if it's a viable solution.
Again, I would really *like* to see a solution developed here; I think it
would be very useful!
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk