Hi Frank,

>>> Now if the implementation file is compiled without debug, but a certain
>>> client file of the header is compiled with debug=1 (resulting in
>>> OSL_DEBUG_LEVEL > 0), will this client file crash, or are the debug- and
>>> non-debug "versions" of DebugBase binary compatible?
>> DebugBase is an empty class in both cases, I expect this to work (never
>> tested!). But I would avoid such scenarios, because it violates the One
>> Defintion Rule (ODR). Nobody can garantee this works on all compilers.
> 
> 
> Why does this violate the ODR? Not sure if I made my case clear ... assume:
> 
>   class Foo : public DebugBase< Foo >
>   {
>   private:
>     int m_foo;
>   public:
>     inline int getFoo() const { return m_foo; }
>   };
> 
> If one client of this class would be compiled with and one without
> debug, and DebugBase would add a member, then one client would probably
> create an access violation (or simply get nonsense) upon calling getFoo().
> 
> Where's the violation of the ODR here?

Foo(compiled without debug) is different from Foo(compiled with debug),
because DebugBase's definition has changed. IMO doing this across
compilation units violates the ODR
(<http://en.wikipedia.org/wiki/One_Definition_Rule>).
Again: I don't expect a problem, especially if you use DebugBase's
members only non-inline (ctor/dtor) and inherit DebugBase "protected".

>>> Sorry for being that inquisitive :)
>> BTW: We've had discussion about this last year:
>> <http://www.openoffice.org/servlets/ReadMsg?list=dev&msgNo=15366>
>> DebugBase has been the outcome.
> 
> I remember this discussion, I just missed interesting details in the
> announcement :)
> 
> My question for the OSL_DEBUG_LEVEL is because in the past, I've been
> bit by problems similar to the one described above. Usually, I don't
> think making such diagnostics depend on OSL_DEBUG_LEVEL is a good idea -
> I prefer DBG_UTIL, since here you *cannot* compile different files with
> different switches. DBG_UTIL is either ON or OFF, globally, while
> OSL_DEBUG_LEVEL might be different for different files.

If DBG_UTL or something similar constant would be used, then you could
not recompile a file for quick DebugBase diagnosis. IMO (full) diagnosis
on pro-builds is still a wanted feature, of course with the stated caution.

regards,
-Daniel

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to