I am wondering if the following is a C fragment in which the definition fcannot repeat what the flink has static, true:
static int f(int);
int f(int x) { return x; }
Clang does not give any warnings. I read section 6.7.1 of the C11 standard without finding an answer to my question.
One could imagine more questions in the same vein, for example, t1.c and t2.c below, and it would be nice if the answer was general enough to apply to some of them, but I'm really interested about the first example above.
~ $ cat t1.c
static int f(int);
int f(int);
int f(int x) { return x; }
~ $ clang -c -std=c99 -pedantic t1.c
~ $ nm t1.o
warning: /Applications/Xcode.app/…/bin/nm: no name list
~ $ cat t2.c
int f(int);
static int f(int);
int f(int x) { return x; }
~ $ clang -c -std=c99 -pedantic t2.c
t2.c:3:12: error: static declaration of 'f' follows non-static declaration
static int f(int);
^
t2.c:1:5: note: previous declaration is here
int f(int);
^
1 error generated.
source
share