Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

simple doubt on declaration

Status
Not open for further replies.

ghostrider123

Newbie level 3
Newbie level 3
Joined
Nov 20, 2012
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,298
Can anyone plz give an example for this statement"a function can have many declaration but only one definition"?
 

please specify the language - in context of C++ virtual function can have more than one definition .... but using key word extern in C we can have one function declared in multiple files with single definition thus the statement that you said is true for one project with multiple files....

with regards,

milind
 

Sir thankyou for your answer but I m little bit confused..So as i Understand suppose there is a function foo() declared in multiple files ie its prototype is mentioned is mentioned in multiple files..So my doubt was that where is its definition done is it in anyone of the multiple files?
 

yes but to access the function you need prefix the function definition with extern key word that gives you the scope of that function externally .....thus such function can be defined one C file and can be declared in multiple file.....try this exercise .....define the function in foo() in file1.c with extern keyword then make file1.h file for include operation ....create file2.c and just declear the function foo(); in file2.c the compilation will go through as language support this aspect....at the end of the story the function call are related to address at which the subroutine / function is stored....

good luck
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top