C Programming help .....wtf ?!?!

Alma J Wetzker almaw
Sat Jan 29 15:25:53 PST 2005


Ben Duncan wrote:
> And while we are on this subject ....
> 
> Can anyone point / help me with C coding standards.
> Like what variables names should be, if used external or internal,
> static ..etc..etcc.
> 
> Where typedef/structure definitions and allocations should be and go
> in a multi-file program system ....
> 
> I have gottena lot of things working with SLAG, but I want to clean up
> up the source before doing an initial release of it.

You should not need to worry about local variables, even if they are static. 
Global variables, definitions and functions are where name collisions take 
place.  I like to prepend a library/module title to the name of the functions 
and definitions.  So

int  foo(struct bar c);

becomes

int  lib_foo(struct lib_bar c);

You can come up with whatever naming convention you like, of course, keeping 
it unusual will help it stay unique, and keeping the names connected to a 
module or library will help with troubleshooting/debugging/coding.

just my $0.02

     -- Alma


More information about the Linux-users mailing list