of topic: C programming style

René Schmitz uzs159 at uni-bonn.de
Tue Nov 21 00:12:22 CET 2000


At 20:44 20.11.00 +0100, Martin Czech wrote:
>What is the usuall C programming style with regard to 
>headers and includes?
>
>I guess .h contains no actuall code?

Mostly these are only definitions and pre-processor macros.

>I understand that something.h should contain some switches,
>defines and function prototypes with some comments
>of all functions in something.c, which contains all the sources.

I used to see/use *.i files for includes that actually contain c-code.

>Is this so?
>What is the proper path for  such inlcudes?

When you write 
#include <some.h> the compiler will look in its default include directory,
#include "thisnthat.h" the compiler will look in the same directory as the
file containing the line is in.

>Why do I need only to include math.h
>for all mathematicall functions, I mean there is no function
>code in it. 

*.h files are merely a definition for the type checking of the functions,
its the linker who actually puts in functions like "sin" or "atanh" from
the libraries into your executable. 

>How does the compiler know where to get the code for some
>something.h header file? 

The compiler actually doesn't know, its the linker who does. And hence the
headers, to tell the compiler, prior to linking, what kinds of arguments a
particular function will expect. Generating a compile-time error, rather
than a run-time error.

Bye,
 René

-- 
uzs159 at uni-bonn.de
http://www.uni-bonn.de/~uzs159

 




More information about the Synth-diy mailing list