Review of Global Variables in C Language

Today, I encountered a tangled problem during the course design process. How to extend the global variables in one file to another file ?

The code is as follows:
test1.c

//External global variable
int SendBuff[SENDBUFF_SIZE];

//Other functions, you can use the global variable above
void othermethod(void)
{
    //...
}

test2.c

//Extend the scope in the global variable to this file
extern int SendBuff[SENDBUFF_SIZE];   

int main(void)
{
    //...
}


Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326787686&siteId=291194637