Re: variadic functions

On 3 Oct, 10:17, "io_x" <a...@xxxxxxxxxxx> wrote:
"Frank" <merr...@xxxxxxxxxxxxxxxxx> ha scritto nel messaggionews:23c2ebd2-dd31-43b0-8de1-0050cc007de9@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#include <string.h>
int main(void)
 int printf(const char *, ...);

in what i know here you say to the linker to find
"int printf(const char *, ...);"
that could be different from printf in <stdio.h>?

I think you (io_x) could be making the same mistake here that I did
when I first learnt C. I thought that printf was "in" stdio.h, ie that
stdio.h contained the code to do printing. This is not the case.

Headers, such as stdio.h, contain text. This text can be included into
your program, and will have the same effect as if you included that
same text yourself in your program file. In the case of printf,
stdio.h contains a prototype, so that your program knows how to call
printf properly, but it doesn't have a clue what printf actually does.

Somewhere else, for example in a file called something.lib, there is
the actual machine code for printf, and when you link the program the
linker will find this and do the right thing with it, which will
normally involve copying the code into your executable.

My first compiler had six different .LIB files, but this wasn't so
that each only covered some of the functions, the way that .h files
do. They were because the computer had a choice of six different
"memory models" which each required slightly different versions of the
functions. Each .LIB file contained all of the functions.

Hope that helps.