Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constant macros are considered as not being constants #519

Open
JonathanDUFOUR opened this issue Nov 10, 2024 · 0 comments
Open

Constant macros are considered as not being constants #519

JonathanDUFOUR opened this issue Nov 10, 2024 · 0 comments

Comments

@JonathanDUFOUR
Copy link

Describe the bug
When defining a macro to an arithmetic constant value using the #define preprocessor directive, the norminette outputs an error saying it is not constant. A similar issue had already been opened before (#357), but the problem seems to not have been fixed. Also, the solution to directly put the resulting value isn't by making the code as readable as possible, as sometimes precise how we get this result is important to not making it a magic number. For example, if the documentation says the bit at position 31 of a specific bitfield corresponds to a specific flag F, then it's much more readable and consistent to define it as 1<<31 than 0x80000000, 0b10000000000000000000000000000000, or even worse, 2147483648.

Erroneous code

#define I_AM_A_CONSTANT 1<<31

Additional infos
norminette 3.3.55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant