C Programming - Declarations and Initializations - Discussion

Discussion Forum : Declarations and Initializations - General Questions (Q.No. 4)
4.
Is there any difference between following declarations?
1 : extern int fun();
2 : int fun();
Both are identical
No difference, except extern int fun(); is probably in another file
int fun(); is overrided with extern int fun();
None of these
Answer: Option
Explanation:

extern int fun(); declaration in C is to indicate the existence of a global function and it is defined externally to the current module or in another file.

int fun(); declaration in C is to indicate the existence of a function inside the current module or in the same file.

Discussion:
56 comments Page 3 of 6.

Hasi said:   1 decade ago
Global function is nothing but the variables which are used for overall program. Where as local variables are used in specific function or a specific part of the program.

Smsirajmuneer said:   1 decade ago
'extern' is similar to the gloabal declaration we can access any where in the program module, similar to accessing the functions in .dll files from various .exe files.

Mumukshu said:   1 decade ago
The answer is incorrect. In C language, by default all function declarations are extern as C does not support local functions. Extern func(); and func(); are the same.

Vijay sawant said:   1 decade ago
extern int a;

extern keyword tell the compiler, identifier a of type integer define anywhere through the program. This statement is just declaration.

Eshwar said:   1 decade ago
Hi,

How is extern function different from normal function?

If a function is declared as extern, then that function can be overrided?

Coder said:   1 decade ago
All functions are defined as extern in default.
If we declare a function as, int foo() actually it is taken as
extern int foo.

Ganesh said:   1 decade ago
Hi sir you said extern is globally declared where as int fun you said localy declared so how you can so it is not different.

Ranjith said:   8 years ago
What the extern function to do?

But how could you say that there is no difference between the two? Please tell me.

Ragaveni said:   1 decade ago
Variables which are declared before main function i.e. not in any function are called global variables.

Venkatramulu said:   1 decade ago
I didn't got suitable answer for "extern" keyword can any one explain with example? please ?


Post your comments here:

Your comments will be displayed after verification.