On Fri, 27 Aug 2010, Thomas Grill wrote:
Is the only possibility, to declare the "::new" operators as static inline or so, in the *.h files ? (I think I did that for a while in GF, but I removed those completely several years ago because I wasn't really using them anymore)
I ithink using an anonymous namespace (a more recent C++ language feature) would be possible...
The anonymous namespace feature is there because of the 'static' mess in C++. This mess comes from the expansion of the original meanings of 'static' in conflicting ways (this comes from the C language's double meaning of 'static' in the first place).
So really, anonymous namespaces are only needed when you need to hide symbols in this compilation so that the linker doesn't see it, but in a context where the 'static' word already means «this is a class variable instead of an object variable» or «this is a class method instead of an object method». Incidentally it can also be used as a shortcut for not having to write "static" in front of 242 different names.
I just wrote this because I thought you could say static in front of a global operator new, but one can't, so, yes, it has to be using anonymous namespaces...
however, using namespaces in flext would make flext-based projects backwards incompatible.
But do people use flext as .so file ? if not, then any old code will run with an old version of flext while a new one gets installed. I say that because the only change would be to make the global 'operator new' a part of the .h instead of the .a ...
Alternately, I suppose you can achieve a lot of the same effect by putting operator new in a common superclass, but it depends on what you use 'operator new' for...
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard on the road (in Îles-de-la-Madeleine, QC).