简体   繁体   中英

macro collisions in third party libraries

I'm using yojimbo - a networking library and spdlog - a logging library for a game that I'm working on. When I try to compile a source file with headers of both yojimbo and spdlog, I get macro collisions resulting in lots of errors given by g++.

Source files with either of the headers but not both compile ok.

Is there a way to avoid macro collision in these third party libraries?

Is there a way to avoid macro collision in these third party libraries?

Yes. Simplest solution is to not include both headers that define the conflicting macros into same translation unit. If that is not sufficient, then one potential solution is to undefine the conflicting macro after including first one. If you need both macros, then you can rewrite it with another name after the undefinition.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM