Re: [OT] What is a 'header' file?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Mario Steele wrote:
> 
> ZNorQ wrote:
> > 
> > Derek Parnell wrote:
> > > 
> > > ZNorQ wrote:
> > > > 
> > > > I'm not quite sure what a header file is.
> > > 
> > > Header files are used by the C and C++ languages. 
> > > 
> > > They generally contain definitions that are used by a C/C++ program.
> > > Specifically
> > > they contain definitions of routines but without the actual details of the
> > > routines'
> > > implementation, just the name, return type, and parameter signature. For
> > > example...
> > > 
> > >    int foo(char *, int);
> > > 
> > > This says that there is a routine called 'foo' that returns an 'int' and
> > > accepts
> > > as parameters a pointer to a 'char' and an 'int', declared somewhere else.
> > > The
> > > compiler uses this information so that when it comes across a call to the
> > > routine,
> > > it can validate the parameters on the call, and how the return value is
> > > handled.
> > > It can do this before it eventually comes across the actual routine's
> > > implementation
> > > details.
> > > 
> > > A header file might also contain struct and class definitions, but again
> > > it
> > > doesn;t have to have implementation details, just the layout of the data
> > > items
> > > in them.
> > > 
> > > eg.
> > > 
> > >    class Bar {
> > >        int abc;
> > >        char* ddd;
> > >        float xyz;
> > >     }
> > > 
> > > Then, when the compiler comes across a reference to an object of the class
> > > 'Bar',
> > > it knows enough to check that the reference is valid.
> > > 
> > > Header files are useful for single pass compilers because it means that it
> > > can
> > > deal easily with forward references.
> > > 
> > > Header files are not needed for multiple pass compilers.
> > > 
> > > 
> > > -- 
> > > Derek Parnell
> > > Melbourne, Australia
> > > Skype name: derek.j.parnell
> > 
> > Ok. As for Euphoria, are we just talking about include files in general, or
> > would there be a categorization between an include file containing a
> > collection
> > of procedures and functions, and those who acts like interfaces between Eu
> > and
> > DLLs? 
> > 
> > Kenneth/ZNorQ
> 
> In Euphoria, there is no specific "header" file type.  All includes contain
> code in them.  There would be no need for that distinction.  You can write
> code
> to link between Euphoria and a DLL/SO, directly into the main ex/exw/exu file,
> and it would work just as fine, if you write it in a e/ew file.  So there's
> no direct corilation between a "header" file that is used by C and Euphoria.
> 
> Mario Steele
> <a
> href="http://enchantedblade.trilake.net">http://enchantedblade.trilake.net</a>
> Attaining World Dominiation, one byte at a time...

Ok, thanks for the feedback, Mario. :)

Kenneth/ZNorQ

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu