Prevent linker from unnecessary symbol resolution

S

Srikanth Madani

Hi all,
Suppose I have a C file fun1.c containing two functions:

__________
void func1() {
printf("\nIn function func1()\n");
}
void func2() {
func3();
}
___________

and another called hello.c containing:

___________
void main() {
func1();
}
___________

Is it possible to create a staticly linked binary using just these two
source files? Or do I have to provide a function definition for
func3(), even though it is not called by main (directly or
indirectly)?

Cheers,
Srikanth Madani
 
M

Mark McIntyre

Is it possible to create a staticly linked binary using just these two
source files? Or do I have to provide a function definition for
func3(), even though it is not called by main (directly or
indirectly)?

AFAIK thats completely compiler/linker dependent. I can imagine a good
linker optimising out the unused func2, and a bad one leaving it in. You'd
have to experiment or ask in a group specialising in your compiler.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top