-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Closed
Labels
Type: InvalidOff topic for this repository, or a bug report determined to not actually represent a bugOff topic for this repository, or a bug report determined to not actually represent a bug
Description
Hi.
Here are two seemingly equivalent versions of program code.
=============================================================
#define BOARD_MODE_NONE 0
#define BOARD_MODE_1 1
#define BOARD_MODE_2 2
#define BOARD_MODE_1_2 (BOARD_MODE_1 + BOARD_MODE_2)
#define BOARD_MODE_HARD 255
#define BOARD_MODE BOARD_MODE_1_2
#if BOARD_MODE == BOARD_MODE_HARD // It's false. Block 2 is defined. It's OK.
// Some block 1
#else
// Some block 2
#endif
=============================================================
enum tBoardModes{
BOARD_MODE_NONE = 0,
BOARD_MODE_1 = 1,
BOARD_MODE_2 = 2,
BOARD_MODE_1_2 = (BOARD_MODE_1 + BOARD_MODE_2),
BOARD_MODE_HARD = 255
};
#define BOARD_MODE BOARD_MODE_1_2
#if BOARD_MODE == BOARD_MODE_HARD // It's true! Block 1 is defined! What a hell !!!
// However, the values of all IDs remain correct !!!
// Some block 1
#else
// Some block 2
#endif
=============================================================
As it turned out, they are not so equivalent…
Bye.
Metadata
Metadata
Assignees
Labels
Type: InvalidOff topic for this repository, or a bug report determined to not actually represent a bugOff topic for this repository, or a bug report determined to not actually represent a bug