__FILE__ macro will be concatenated to previous string accidentally in C -
this question has answer here:
this simplest example of question:
#include<stdio.h> int main() { printf("%s:%s\n", "i in file" __file__); }
when forget insert comma before "__file__" macro, expect compile error, warning. output be:
i in filetest.c:[c
- 1st string : "i in file" concatenate __file__ macro
- 2nd string undefined
could tell me why not compile error?
while possible compiler in e.g. printf
, scanf
(because knows format-strings functions), can't done variable-argument functions.
if create vararg function, how compiler know number of arguments correct? answer can't. therefore c specification doesn't has error.
that compilers (some, not all) give warnings printf
, scanf
because creators of compiler nice enough add it. it's not required.
Comments
Post a Comment