所以,讓我們說,我有:可以在C中聲明一個靜態變量extern:
file1.c
int i;
static int j;
int main()
{
for (int k = 0; k < 10; k++)
{
int foo = k;
}
}
file2.c
{
// the following statements are before main.
extern int i; // this is acceptable, I know since i acts as a global variable in the other file
extern int j; // Will this be valid?
extern int foo; // Will this be valid as well?
}
因此,我有一個疑問,打上一個問號的聲明,他們會有效嗎?
這可以幫助您http://stackoverflow.com/questions/2841762/why-wont-extern-link-to-一個靜態變量 – HighPredator
什麼阻止你問你的編譯器? – molbdnilo
這個問題沒有任何意義,extern和static是彼此的對立面。你實質上是在問:「紅車在紅色的時候可以變成藍色嗎?」。 – Lundin