Automatically selecting between static assert and runtime error
问题 I have macro that performs a division and checks alignment. #define BYTES_TO_WORDS(x) ((CHECK_ALIGNMENT(x,2)) * ((x) / 2)) I would like to implement CHECK_ALIGNMENT as a macro that always returns 1, and triggers an error if x does not divide by 2. The macro BYTES_TO_WORDS is called from different contexts, sometimes with x as a compile-time constant integer expression and other times with x as an integer expression that is resolved on runtime. Is it possible to implement CHECK_ALIGNMENT such