answersLogoWhite

0

What is the function of keyword extern?

Updated: 12/23/2022
User Avatar

Nitin

Lvl 1
18y ago

Best Answer

The extern keyword declares a variable or function and specifies that it has external linkage (its name is visible from files other than the one in which it's defined). When modifying a variable, extern specifies that the variable has static duration (it is allocated when the program begins and deallocated when the program ends). The variable or function may be defined in another source file, or later in the same file. Declarations of variables and functions at file scope are external by default. In C++, when used with a string, extern specifies that the linkage conventions of another language are being used for the declarator(s). C functions and data can be accessed only if they are previously declared as having C linkage. However, they must be defined in a separately compiled translation unit. Microsoft C++ supports the strings "C" and "C++" in the string-literal field. All of the standard include files use the extern "C" syntax to allow the run-time library functions to be used in C++ programs. If you find this info useful Please vote!!!

User Avatar

Wiki User

18y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the function of keyword extern?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Is global variables are declared within the main function?

Might be, but don't forget the keyword 'extern':int main (void){extern int errno;...}


Is possible define a structure with extern keyword?

extern is used only when there is a variable or a function name. so here's what you can do, typedef struct{ int data; }my_struct; extern my_struct my_new_struct; Compilers takes this as a *type*.


How java use extern key word which is used in C plus plus?

No extern keyword in Java.


Which keyword is used to make function call faster in c?

Inline Function


Which is the keyword used to limit the scope of a function to the file in which it resides?

Declare the function static.


Which is the keyword used to limit the scope of the function to the file in which it is reside?

Declare the function static.


How do you make a variables from outside a function work in that function?

declaring a variable before main() will be accessed in main as well as in function which is called a "global variable" or "external variable". *edit* a very good programming practice, which is also necessary with some compilers, is to declare the variable inside the function as well with the extern declaration before the type declaration. for example if you had this inside a function: int func(){ int x = 0; x++; return x; } that would be fine, but to declare it externally, you should include extern inside the function int x = 0; int func(){ extern x; x++; return x; } assuming that we declared the variable globally, which we did.


What does extern C stand for?

"extern" is short of "external" which means outside.


What does the new function do?

The new keyword creates a new Object.


Is it true global variable may have several declaration but only one definition?

Yes, indeed it is. In all the declarations, you need to use the keyword "extern". Rgds, Karthick S.


What is extern C used for?

extern specifies that the variable is in another file.say you have a variable(int k = 10) in mycpp1.cpp and you want to use it in mycpp2.cpp use the extern to redeclare the variable and use it.Example:Code://mycpp1.cppint k = 10;Code://mycpp2.cppextern int k;void function(void){cout


Python keyword indicates the start of a function definition?

The word "def", short for definition starts a function.