I have defined macros as below.
#define FALSE 0
#define TRUE (!FALSE)
What will be the data-type of TRUE and FALSE? What literal value does TRUE take after preprocessing? Is it compiler dependent? Why?
#define preprocessor directive (macros) are meant to do textual replacement. It will replace all occurrence of FALSE to 0 and TRUE to !0 that essentially gets evaluated to 1. So, the resultant data type will be same as 0 and 1. i.e., integer.
Regarding the usage of ! operator, it always produces a result of type int.
Quoting the C11 standard, chapter §6.5.3.3 (emphasis mine)
The result of the logical negation operator
!is 0 if the value of its operand compares unequal to 0, 1 if the value of its operand compares equal to 0. The result has typeint. [...]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With