C (193/257)

From:
Date:20 Feb 2001 at 19:19:24
Subject:Re: includes and stuff

--- Joris Kempen <Trekker@studenten.net> a écrit : >
Hello,

Hi too,

>
> I'm trying to make some functions for myself to make
> programming easier, i
> want to put them in a seperate .h and .c file but i
> don't know how to
> organize it.

Cool,

> I'll give an example:

[...]

> So that's the header file, but then i did some
> thinking and had some
> questions: the function needs the asl.library and
> the asl.h to work
> properly. But when you need to open a libary you
> also need the Exec.h files
> included. My question where to put those?

I think it should be in the .c file. These headers are
only used INSIDE the function (and not need for
passing argument), so it will speed up compilation :
asl.h will not be readed for compiling all stuff that
include your .h

> And should i really open those libraries in my
> function or should it be a
> request before you use the function itself?

Should be openned before you use this function.
It's means you should check inside your function if
libraries are open or ... use autoopen capability of
many compilers.

> Then i started writing the myfunctions.c,
> i wrote it, i'll give you the source for it (hasn't
> been tested, some maybe
> lot's of bugs, just for the idea)

[...]

>
> So i found out, i needed the string.h include to be
> able to use the strcat
> function, again i don't know what to do: put a
> #include <string.h> in this
> myfunctions.c file, or should it be in my
> myfunctions.h file...

In myfunctions.c !

> Maybe you don't get all my problems, but the
> mainpoint is: how to organize
> such things to put some things in seperate files.
> Till this time i always
> just one file with all the code scrammed into it,
> and i want to start
> reorganizing my code.

The rule is :

- if it's something used by the interface (struct,
typedef, etc ... used in the .h file) the place is in
the header.
- if not, it's in the .c file.

Bye

Laurent

=====
The misspelling master is on the Web.
_________
/ /(
/ Dico / / 100 % Dictionnary Free !
/________/ /
(#######( /

Quoi, des fautes d'orthographe! Pas possible ;-D.

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/

------------------------ Yahoo! Groups Sponsor ---------------------~-~>
eGroups is now Yahoo! Groups
Click here for more details
http://click.egroups.com/1/11231/0/_/451227/_/982693166/
---------------------------------------------------------------------_->