Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_linux_programming thread: some questions


Message #1 by "Serban Udrea" <S.Udrea@g...> on Thu, 10 May 2001 10:55:51 -0100
--- Serban Udrea <S.Udrea@g...> wrote: > Hello,
> 
> This are some questions I have, sorry if not really
> at pro level.
> 
> In one of my codes I'm using lstat() to gatter
> information about some files
> (directories) used by the program. If I compile the
> code with -Wall there is no
> problem but if I add -ansi I get the following
> warning:
> 
> implicit declaration of function `lstat'
I believe this will be because lstat is not part of
the ansi specification.  To get rid of the warning you
will need to decalre the prototype yourself and then
add some notes to your documentation (;-)) for the
benefit of people porting to other systems.
> 
> I couldn't get read of it and on the other hand I
> would like the code to be ANSI
> compliant (in the hope of enhanced portability).
> Using stat gives no warning but stat follows links
> and I would like to detect
> links. How can I "see" if a given file is a link or
> not, in an ANSI way (if I
> can say so)? Or shouldn't I care about that warning.
> 
> My second question is about modular code. How is
> this done in C? Every now and than

I would do it in C++ and just derive from a base class
each new object with the required different behaviour.
 When a new object is added you will not need to
recompile existing objects unless they are all in the
same source file.

Apologies if you cannot do it in C++.

With regard to your example you would need some kind
of field base class where you derive different sub
classes based on the change in behaviour.

> I'm reading about the advantages of having such code
> instead of, say, monolitic one.
> 
> To be a little bit more specific. I'm working at
> some code which is intended to
> simulate the movement of particles in different kind
> of fields. I would like to
> compile the code once and than, if there is a new
> kind of field to be added, to
> write just the part describing it and compile it
> separately with no need to
> recompile the rest of the code. How can I achieve
> this?
> 
> Regards,
> 
> Serban
> 

  Return to Index