+ 1
What does a define statement with an identifier but without a value do in C?
Consider this statement: #define FOO What does this code do? I know that this can be used to set flags in C (using #ifdef) but what actually happens when I do something like this? Obviously, 'FOO' won't be replaced by anything.
4 odpowiedzi
+ 2
'FOO' will be replaced by nothing, like literally, nothing.
https://code.sololearn.com/cSlLGZJTOxKP/?ref=app
+ 3
Calvin Thomas
'FOO' must be an individual token. The preprocessor will not replace 'FOO' if it is part of another token, like in 'pFOOf'.
If the preprocessor replaced all occurrences of 'FOO' even when it is a part of another token, you won't be able to have a string "FOO" as it will be changed to "rint".
+ 3
XXX Thank you very much. That too was really helpful
+ 2
XXX That was really helpful. Thanks a lot. And, why doesn't this work?:-
#include <stdio.h>
#define FOO rint
int main() {
pFOOf("Hello World");
}