Ограничить область действия #define ярлыков
Какова правильная стратегия, чтобы ограничить сферу#define
ярлыки и избежать необоснованного столкновения токена?
В следующей конфигурации:
Main.c
# include "Utility_1.h"
# include "Utility_2.h"
# include "Utility_3.h"
VOID Main() { ... }
Utility_1.h
# define ZERO "Zero"
# define ONE "One"
BOOL Utility_1(); // Uses- ZERO:"Zero" & ONE:"One"
Utility_2.h
# define ZERO '0'
# define ONE '1'
BOOL Utility_2(); // Uses- ZERO:'0' & ONE:'1'
Utility_3.h
const UINT ZERO = 0;
const UINT ONE = 1;
BOOL Utility_3(); // Uses- ZERO:0 & ONE:1
Note: Utility _1
, Utility_2
а такжеUtility_3
были написаны независимо
Error: Macro Redefinition and Token Collision
Also, Most Worrying: Compiler does not indicate what replaced what incase of token replacement
{Редактировать}Note: This is meant to be a generic question so please: do not propose enum
or const
i.e. What to do when: I MUST USE #define
& _Please comment on my proposed solution below.. __