How to handle a class name conflict when porting old code?

后端 未结 5 1611
情话喂你
情话喂你 2021-01-05 23:04

I\'m trying to port an old library (that doesn\'t use namespaces as far as I can tell) to modern compilers. One of my targets can\'t tell the difference between System::TObj

5条回答
  •  悲&欢浪女
    2021-01-05 23:13

    You can do as Dib suggested, with a slight modification:

    // In a wrapper header, eg: include_oldlib.h...
    
    namespace oldlib
    {
       #include "oldlib.h"
    };
    
    #ifndef DONT_AUTO_INCLUDE_OLD_NAMESPACE
    using namespace oldlib;
    #endif
    

    This allows you to #define the exclusion in only the files where you're getting conflicts, and use all the symbols as global symbols otherwise.

提交回复
热议问题