function

Rajesh M. Kanojia's Avatar, Join Date: Dec 2012
Go4Expert Member
dear members
can any one tell me where exactly function get loaded at run time in c program.
ex:-
suppose i call 2 function in main().
1- abc();
2- xyz();
my question is that is abc() and xyz() occupy memory if yes then where
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
Why do you want to know?

They are loaded with main in the TEXT part of the executable. You will need to learn assembly language programming to know what that really means. Hence the above question. If you want to know the addresses of the functions, that's simple, just define a function pointer to point to those functions, then pass the pointer into printf and use the format mask %08lx to display the address.
0
iranjit's Avatar, Join Date: Jan 2013
Newbie Member
I am sorry but, it is hard to understand your question.

Overloaded functions have same name but, different arguments(either different number of arguments or different types of argument). Remember, if two functions have same name and argument/s but different return type then, don't assume these two functions are overloaded functions. Instead compiler gets confused and displays error.

If there are two overloaded functions then, compiler doesn't know which function to call until run-time and executes the appropriate function in accordance with the argument passed.
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
"Why do you want to know" is not a difficult question to understand. But I can't answer your original question until I know, er, why you want to know.

Your original question has nothing to do with overloaded functions because abc() and xyz() differ in name. But with overloaded functions they differ in parameters so the compiler can tell which function to call by looking at the parameters. So if you have abc() and abc(int), then the compiler can determine which to call by whether or not you pass an int, and if you try to default the int param (e.g. void abc(int x=0)) then the compiler will throw an error because it won't be able to determine if a call like abc(); means call abc() or abc(0).

By the way, the term "run time" has nothing to do with the compiler. The compiler compiles the code to object code. The linker links the object code with the relevant libraries to make executable. When you run the program, that is "run-time" and the compiler is not involved.
shabbir like this
0
JonSon's Avatar, Join Date: May 2013
Newbie Member
An action performed by a device department or person that produces a result.The return value of the first non-failed function without executing successive functions .