[ale] [semi-OT] Recommended C programming book?

Christopher Fowler cfowler at outpostsentinel.com
Fri Aug 8 09:00:12 EDT 2003


On Fri, Aug 08, 2003 at 07:37:35AM -0500, Kevin Krumwiede wrote:
> On Fri, 08 Aug 2003 08:19:36 -0400
> Geoffrey <esoteric at 3times25.net> wrote:
> 
> > Modular programming is little more than breaking the code down into 
> > routines based on the purpose of the code.
> 
> I understand the concept from my experience with Java.  I've looked into the source code for a couple OSS projects to fix what I expected to be simple bugs, but quickly found myself lost.  When I wrote C programs in high school, they generally consisted of one .c file and one .h file, not umpty-fratz .c files with one function in each!
> 

I do this so that it is easily manageable.  When you do the build using make,
ld (linker) will merge all the objects created into one binary


Here is an example of why you see N .c files.  In the list below each
write_opsSrenaXXX.c file is roughly 100 lines. There are 33 files.  By placing
each function into a seperate file it makes it easier to manage it all.


[cfowler at cfowler DEVEL snmp-agent]$ ls *.c
getBufferTail.c                write_opsSrenaNtpEnabled.c
outpost2.c                     write_opsSrenaNtpTimeserver1.c
outpost.c                      write_opsSrenaNtpTimeserver2.c
outpostUtils.c                 write_opsSrenaNtpTimeserver3.c
rs232.c                        write_opsSrenaPortBufsize.c
tbuf.c                         write_opsSrenaPortMode.c
write_opsSrenaAudit.c          write_opsSrenaPortName.c
write_opsSrenaBootFile.c       write_opsSrenaPowerStatus.c
write_opsSrenaBootServer.c     write_opsSrenaRestartSystem.c
write_opsSrenaBootSource.c     write_opsSrenaSaveConfig.c
write_opsSrenaBootUrl.c        write_opsSrenaSnppEnabled.c
write_opsSrenaConfigFile.c     write_opsSrenaSnppPort.c
write_opsSrenaConfigServer.c   write_opsSrenaSnppServer.c
write_opsSrenaEmailRelay.c     write_opsSrenaSyslogPort.c
write_opsSrenaEmailUser.c      write_opsSrenaSyslogRecvEnabled.c
write_opsSrenaNetConActive.c   write_opsSrenaSyslogRemoteEnabled.c
write_opsSrenaNetConBufsize.c  write_opsSrenaSyslogServer.c
write_opsSrenaNetConHost.c     write_opsSrenaTrapHost1.c
write_opsSrenaNetConName.c     write_opsSrenaTrapHost2.c
write_opsSrenaNetConPort.c

When I do the build all are brought together.  Look at it like java.  Each
class can be in a seperate file.  Its up to the programmer how he/she wants to
group stuff.  Normally in libraries I create one file for each function.  

> I want a book that explains that design pattern, and especially the details of data hiding in C modules.  (I found some semi-helpful stuff about the 'static' keyword online.)  I'm going to see if I can find the book Fletch suggested...
> 
> Thanks,
> Krum
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list