Re: header file in C

From: Malcolm (malcolm_at_55bank.freeserve.co.uk)
Date: 10/18/04


Date: Mon, 18 Oct 2004 22:32:51 +0100


"candy" <candy_init@yahoo.com> wrote
>
> I just want to know that whether the C header files( like stdio.h,etc
> which the compiler provides) just contains the function declarations
> or they also contain some additionalinformation like where to look in
> the memory for the defintions of the standard functions like
>
If you look at a standard header file by opening it in an editor, you'll
probably find something that looks superficially like gibberish, but when
you examine it closely is a regular C header.
However not all implementations are like this. The compiler isn't required
to have standard headers as actual files.
As for "finding the function in memory", all library or object file
functions need to be located somehow. The standard libary is no different.
>
> scanf(char*c,...)).
>
> Also,if there is no information about the location of the memory where
> the definitions of the standard functions is present,then can we just
> declare the function which we want to use,ourselves,and then don't
> include the required header file/s.
>
This will probably work, and language lawyers will be able to tell you
whether or not behaviour is defined. However for practical purposes we never
do this. If scanf() is available then stdio.h will also be available, and so
is always included.
>
> Also,can you please tell me the steps in brief through which a typical
> complier passes the source file so as to generate the final executable
> file.
>
It first runs the C preprocessor on the file. Then it compiles all the
function definitions to an intermediate format, known as object code, then
it invokes the linker to join the object files and library files into an
executable.
>
> Also,can you please tell me that why an executable file made in Windows
> operating system is not recognised by the Linux operating System and
> vice-versa.
>
Through wickedness. The processors are the same, and so the machine code is
basically identical. However the operating system writers have decided to
make the minor loading and initialisation code incompatible, so programs
won't run on each other's platforms and lawsuits / competition is avoided.



Relevant Pages

  • Re: Header Files and Interfaces Yet Again
    ... compiler is not allowed to read them. ... illustrate the difference of header file and fake header. ... fake headers can not serve as sufficient information to the ... > something but it appears to me the Standard Library is not designed ...
    (comp.lang.cpp)
  • Re: Header Files and Interfaces Yet Again
    ... >> headers to feed to the compiler. ... But he actually uses what you call a fake header. ... I'm not really srue why header files that present things that aren't ... >> something but it appears to me the Standard Library is not designed ...
    (comp.lang.cpp)
  • RfD: :NAME
    ... I posted this RfD to the Forth-200x group (originally called HEADER) ... surface of the compiler, is standard. ... There is no good way to construct colon words from within other colon ...
    (comp.lang.forth)
  • Re: Standard library confusion
    ... that's a standard C++ header. ... > This, although it claims to be compiled for the gcc compiler, seems to ... The "gcc" compiler is a C compiler. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Dual-core systems - AMD - Windows Vista
    ... I don't build with the assembler code. ... It is made more difficult because various compiler accept different ... deviations from the standard. ... I added zillions of missing function declarations, ...
    (comp.protocols.time.ntp)