Automatic (function scope) variables
A variable declared within a function can only be used within the scope of that function.
// LNK2019_AV.cpp
// compile with: /c
void test(void);
static int lnktest3 = 3;
int lnktest4 = 4;
int main() {
static int lnktest1 = 1;
int lnktest2 = 2;
test();
}
and then,
// LNK2019_AV_2.cpp
// compile with: LNK2019_AV.cpp
// LNK2019 expected
extern int lnktest1;
extern int lnktest2;
extern int lnktest3;
extern int lnktest4;
void test(void) {
int i = 0;
i = lnktest1;
i = lnktest2;
i = lnktest3;
i = lnktest4; // OK
}
See also
Feedback
https://aka.ms/ContentUserFeedback.
În curând: Pe parcursul anului 2024, vom elimina treptat Probleme legate de GitHub ca mecanism de feedback pentru conținut și îl vom înlocui cu un nou sistem de feedback. Pentru mai multe informații, consultați:Trimiteți și vizualizați feedback pentru