We have a C++ Builder application that has lived through many versions of Embarcadero RAD Studio. Now I was trying to get it to compile in XE2 and ran into a problem where a class called TGroup became ambiguos with the TGroup class of Winsock.
To my anger I found that the initial architects of the system didn't use any namespaces, which would have solved this problem. I decided to add all the project code to a single namespace to start with. But pretty soon it dawned on me that I would have to go through about 1400 .h and .cpp files.
Please, for the love of god... Is there a good tool out there to quickly encapsulate an entire project within a namespace?
Most of the files differ a bit in layout. Some have defines after the includes and some do not etc. But to just insert the namespace declaration after the includes should probably work ok to start with and then close it just before the last #endif, which is the inclusion guard #define.
Check if the offending header files already use namespaces. All VCL-based header files DO use namespaces, but they also have using namespace
statements at the bottom to dump everything into the global namespace by default. Most versions have special #define
values you can set to disable that behavior.