schanti schul
schanti schul

Reputation: 711

static and non-static variable definition at the start of the file difference

Looking at an ST example file for one of its devices.

On the same .c file there are different definitions.

Curious to know what might be the reason for some of the definitions to be static and some not.

PLACE_IN_SECTION("BLE_DRIVER_CONTEXT") static tListNode HciAsynchEventQueue; // static

PLACE_IN_SECTION("BLE_DRIVER_CONTEXT") static TL_CmdPacket_t *pCmdBuffer; // static

PLACE_IN_SECTION("BLE_DRIVER_CONTEXT") HCI_TL_UserEventFlowStatus_t UserEventFlow; // not static

All appear at the top of the file . One after another. All are used inside the file only.

Upvotes: 0

Views: 335

Answers (1)

0___________
0___________

Reputation: 67476

static file level (global) variables do not have external linkage and will not be seen from other compilation units (more simple files). They have the same storage duration as non static variables but their "visibility" is limited to one compilation unit (source file).

Upvotes: 1

Related Questions