EFI Interview Question
Software Engineer / DevelopersStorage: Static Variables are always stored in static area of the program.
Scope: If there are define outside functions (global), then they are visible to all the functions in the file, but not in the other files.
Globals are also stored in the static area, but are visible to all the files that are linked. So functions in other files can link to global variables using extern, but they can link to static variable.
static variables== IF A VARIABLE IS STATIC AND LOCAL THEN FUNCTION DIE BUT THE VRIABLE DOES NOT DIE. THE VARIABLE STILL ALIVE IT DIE WHEN THE PROCESS DIE.
GLOBAL VARIABLE== THESE VARIABLES DIE WHEN THE PROCESS DIES AND THEY ARE ACCESSIBE FROM ONE FILE TO ANOTHER FILE ALSO BY USING THE EXTERN DECLARATION
static variables== IF A VARIABLE IS STATIC AND LOCAL THEN FUNCTION DIE BUT THE VRIABLE DOES NOT DIE. THE VARIABLE STILL ALIVE IT DIE WHEN THE PROCESS DIE.
GLOBAL VARIABLE== THESE VARIABLES DIE WHEN THE PROCESS DIES AND THEY ARE ACCESSIBE FROM ONE FILE TO ANOTHER FILE ALSO BY USING THE EXTERN DECLARATION
Storage: Static Variables are always stored in static area of the program.
- CareerCup August 25, 2011Scope: If there are define outside functions (global), then they are visible to all the functions in the file, but not in the other files.
Globals are also stored in the static area, but are visible to all the files that are linked. So functions in other files can link to global variables using extern, but they can link to static variable.