How do I avoid name collision with macros defined in Windows header files?

后端 未结 8 1374
一向
一向 2020-12-10 11:24

I have some C++ code that includes a method called CreateDirectory(). Previously the code only used STL and Boost, but I recently had to include

8条回答
  •  情歌与酒
    2020-12-10 11:52

    Note that name conflict usually comes from a certain header file being included. Until then stuff like CreateDirectory and GetMessage isn't pulled into visibility and code compiles without a problem.

    You can isolate such an inclusion into a wrapper header file and "#undef whatever" at its end. Then, whatever name collision you have will be gone. Unless, of course, you need to use those macros in your own code (yeah, so very likely...)

提交回复
热议问题