Re: where does the header implentation get inserted



On 17 Sep 2006 09:21:14 -0700, in comp.lang.c , amit.man@xxxxxxxxx
wrote:

i think my question is misunderstood.

suppose i declare a function in "myLib.h". that function has an
implementation - lets say
that that implementation is in "myLib.c"

now if i put the line #include "myLib.h" into some code, i can use the
function of "myLib" in that code. i understand where its get the
function declaration (it's copy the lines of myLib.h into my source
code, in one way or another).
what i dont understand is where it's getting the actual function
implementation.

This is the second part of my original answer.
You have to tell the compiler to compile both files, and then tell the
linker to link the results together to make the executable.

How you do this is compiler-specific. With most compilers you can
chain the filenames together eg

$ cc file1.c file2.c

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
.



Relevant Pages

  • Re: Setting pointer to null!
    ... I think this debugging fetaure emerged originally ... developer forgets to initialize a variable and it accidentally ... to declare a bunch that would be "initialized" in relatively distant code. ... because you prevent the compiler from initializing them ...
    (microsoft.public.vc.language)
  • Re: advice on package design
    ... > for following scope. ... the compiler would have to do ... the extra verbiage required just to declare X. ... Unfortunately this is also untrue in Ada. ...
    (comp.lang.ada)
  • Re: Properties
    ... Is there any reason why this would not work and not simplify the ... Why should I have to declare any variable most of the time? ... The reason you explicitly declare fields used by a property is that the ... compiler needs to know what the code in the property does. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: use of erf intrinsic
    ... while it is also legal to declare a referenced function ... within the calling functionor even block, a la classic FORTRAN, ... The implementation (compiler) is required to check that references ... If you use K&R1 syntax, the compiler is not required to detect ...
    (comp.lang.fortran)
  • Re: Primitive curiosity...
    ... those types after the compiler has already used the information. ... "dispatch table" or something like that. ... contains the addresses of the primitive subprograms of the type. ... When you declare a type extension, ...
    (comp.lang.ada)

Loading