How to prevent macro redefinition

前端 未结 5 515
陌清茗
陌清茗 2021-01-17 09:51

After working some time on my project, this warning begins to appear:

2>Game.cpp
2>c:\\program files\\microsoft sdks\\windows\\v6.0a\\include\\windef.h         


        
5条回答
  •  庸人自扰
    2021-01-17 10:21

    Unfortunately or fortunately, no. There is no such tool that automates it. You have to go read the code in those header files, figure out what is going on and take appropriate actions.

    The most you can do is

    1. Check if macro is defined using ifdef or if defined(...) or if !defined(...) preprocessor constructs.
    2. Undefine macro using undef.

    Only ANSI C considers macro redefinition an error.

提交回复
热议问题