By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,421 Members | 1,127 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,421 IT Pros & Developers. It's quick & easy.

looking for good C source code

P: n/a
Hi all.
I'm looking for good C source code to study and be able to advance my C
programming skills. Do you recomend any open source project in particular
that in your opinion has good writen C code?
Thanks.
Nov 14 '05 #1
Share this Question
Share on Google+
20 Replies


P: n/a
The Linux Kernel.
www.kernel.org

The best free (as in free speech) C code you can get.

On Fri, 26 Dec 2003 20:31:43 +0000, Clark wrote:
Hi all.
I'm looking for good C source code to study and be able to advance my C
programming skills. Do you recomend any open source project in particular
that in your opinion has good writen C code?
Thanks.


Nov 14 '05 #2

P: n/a
stau wrote:
The Linux Kernel.
www.kernel.org

The best free (as in free speech) C code you can get.


I definitely had fun reading version 0.01 of the linux kernel. I
decided to read that version because I figured it'd be the easiest to
read and understand since it is a minimal kernel.

Aaron
--
/usr/bin/fortune says:
Taxes are not levied for the benefit of the taxed.

Nov 14 '05 #3

P: n/a
"Clark" <ja***********@yahoo.com> wrote in
news:bs************@ID-215001.news.uni-berlin.de on Fri 26 Dec 2003
01:31:43p:
Hi all.
I'm looking for good C source code to study and be able to advance my C
programming skills. Do you recomend any open source project in
particular that in your opinion has good writen C code?
Thanks.


This isn't really on-topic for this group. comp.programming would
probably be a better place for it. comp.lang.c only deals with Standard
C, not programming in general or languages other than Standard C.

In any case, the GNU Project has released some coding standards for
people to follow. I think they can be applied generally, in fact, and so
I will give you the link to the website where they are listed:

http://www.gnu.org/prep/standards_toc.html

Another thing for you to keep in mind is the difference between using a
specific language and programming in general.

Using a language is all about knowing syntax rules and taking advantage
of semantics and such like. In other words, it's not applicable to any
other language.

Programming in general deals with algorithm design and structuring of
both code and data and the theory of effective computability. In other
words, it is completely independent of any language.

Perhaps the most important lesson in programming style to take from that
distinction is to learn that structure and planning are the most
important elements of good style, and that they will show through well no
matter what language you use.

Nov 14 '05 #4

P: n/a
In article <pa****************************@pretogal.pt>, st**@pretogal.pt
says...
The Linux Kernel.
www.kernel.org

The best free (as in free speech) C code you can get.


It's free, but it's not C.

The linux kernel uses a lot of gcc extensions that are not pure ISO
or ANSI standard C. That's not bad, it would be hard to write an OS
without doing so, but if your intent is to learn portable C, that's
probably not the place to start.

Sourceforge is a great reasource, try searching for ANSI and ISO and
reading project summaries for those claiming to be fully portable.

Also, several of the regular posters here have websites with
libraries and smaller code samples that are fully portable, try
trolling through some of the .sig lines.

--
Randy Howard
2reply remove FOOBAR

Nov 14 '05 #5

P: n/a
Clark wrote:
Hi all.
I'm looking for good C source code to study and be able to advance my C
programming skills. Do you recomend any open source project in particular
that in your opinion has good writen C code?

(I must disagree with August Derleth about the topicality of this question.
I can think of no better place to ask about good C source code than a good
C newsgroup!)
If you're looking for good C source code, look no further than comp.lang.c.
If you want to advance your C programming skills, you are already at the
right place. Read the group regularly, and (once you have worked out who
knows what they're talking about and who doesn't) you'll pick up a vast
number of useful tips on how to use the language correctly and skilfully.

You don't have to wait for discussions to happen, either, since Google has
archives for this newsgroup going back to - er, no, it even goes back
further than that.

A brief, non-exhaustive list of names worth looking out for (past and
present) - every one of these people is a C expert:

Martin Ambuhl
Christian Bau
Dann Corbit
Douglas Gwyn
Lawrence Kirby
Jack Klein
Ben Pfaff
P J Plauger
Dan Pop
"Noone Really"
Will Rose
Eric Sosman
Richard Stamp
Keith Thompson
Chris Torek
Stephan Wilms
Dik Winter

Like I said, it's non-exhaustive. But basically, if you focus on articles by
these people, you'll pick up a lot of good stuff. Then find out who agrees
with them (on the whole!), and you'll find your way to other clueful
articles.

It's not the best way to /learn/ C, by any means, but if you've already
"learned" C, this is a great way to find out what you got wrong and what
you missed.
--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 14 '05 #6

P: n/a
Richard Heathfield wrote:
[snip] A brief, non-exhaustive list of names worth looking out for (past and
present) - every one of these people is a C expert:

Martin Ambuhl
Christian Bau
Dann Corbit
Douglas Gwyn
Lawrence Kirby
Jack Klein
Ben Pfaff
P J Plauger
Dan Pop
"Noone Really"
Will Rose
Eric Sosman
Richard Stamp
Keith Thompson
Chris Torek
Stephan Wilms
Dik Winter

Like I said, it's non-exhaustive. But basically, if you focus on articles by
these people, you'll pick up a lot of good stuff. Then find out who agrees
with them (on the whole!), and you'll find your way to other clueful
articles.
This list is especially non-exhaustive in that it omits Mr. Heatfield
himself, of course.

A rather funny thought just occurred to me: what would happen if people
of this caliber got together to work on a real-life project? Seems that
a mediocre outcome is out of the question... Either the result would be
quite brilliant or a total deadlock, I think :-)
It's not the best way to /learn/ C, by any means, but if you've already
"learned" C, this is a great way to find out what you got wrong and what
you missed.


It certainly is.

Best regards, Sidney
Nov 14 '05 #7

P: n/a
On Sat, 27 Dec 2003 02:21:28 +0000, Aaron Walker wrote:
stau wrote:
The Linux Kernel.
www.kernel.org

The best free (as in free speech) C code you can get.


I definitely had fun reading version 0.01 of the linux kernel. I
decided to read that version because I figured it'd be the easiest to
read and understand since it is a minimal kernel.

Aaron


Its does have some bugs on the use of the C language, as Linus just
admited when argumenting against SCO dick corp.; like #define
someMacro(a, b) (a - b), in which the argument may be a complex
expression.
A newer version is probably better for study.
Nov 14 '05 #8

P: n/a
"Sidney Cadot" <si****@jigsaw.nl> wrote in message
news:bs**********@news.tudelft.nl...
A rather funny thought just occurred to me: what would happen if people
of this caliber got together to work on a real-life project? Seems that
a mediocre outcome is out of the question... Either the result would be
quite brilliant or a total deadlock, I think :-)


I do agree that the people mentioned know their stuff very well, but you
need more than only coding and language skills to successfully complete a
big project.
Nov 14 '05 #9

P: n/a
"Servé Lau" <i@bleat.nospam.com> wrote in message
news:bs**********@news4.tilbu1.nb.home.nl...
"Sidney Cadot" <si****@jigsaw.nl> wrote in message
news:bs**********@news.tudelft.nl...
A rather funny thought just occurred to me: what would happen if people
of this caliber got together to work on a real-life project? Seems that
a mediocre outcome is out of the question... Either the result would be
quite brilliant or a total deadlock, I think :-)


I do agree that the people mentioned know their stuff very well, but you
need more than only coding and language skills to successfully complete a
big project.


I'm quite sure the listed people would know quite a lot of other stuff too.
:-)

But more critically, a group considering a project that would actually
_need_
more than two (say) genuine C _experts_ should probably reconsider it's
choice
of programming language! ;)

In any case, many of the listed people _have_ colaborated on a real-life
project: "C Unleashed". Although, Francis Glassborow wasn't entirely
convinced of the merits of that project, even if he was satisfied with
the quality of production.

--
Peter
Nov 14 '05 #10

P: n/a
Peter Nilsson wrote:
But more critically, a group considering a project that would actually
_need_ more than two (say) genuine C _experts_ should probably
reconsider it's choice of programming language! ;)
Or perhaps a group that thinks it can get away with using non-experts should
be designing street-signs instead of software.
In any case, many of the listed people _have_ colaborated on a real-life
project: "C Unleashed". Although, Francis Glassborow wasn't entirely
convinced of the merits of that project, even if he was satisfied with
the quality of production.


I hold the opposite position to Francis. I think the project was worth
doing, but I think the timescales involved made it more or less impossible
to provide the kind of quality we'd have been happy with. On the other
hand, perfectionists are /never/ happy with the quality, are they? And if
there's one thing (other than C) that unites clc regs, it's perfectionism.

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 14 '05 #11

P: n/a
"Richard Heathfield" <do******@address.co.uk.invalid> wrote in message
news:bs**********@titan.btinternet.com...
And if
there's one thing (other than C) that unites clc regs, it's perfectionism.


s/rfectionism/dantry ;-)

Seriously, I think CU is a good book. It may have been knocked up in limited
time, but that only shows more about the quality of its authors. It's not a
beginners' book after all, and the others care more about the content than
anything else.
Nov 14 '05 #12

P: n/a
On Fri, 26 Dec 2003 15:31:43 -0500, Clark wrote:
Hi all.
I'm looking for good C source code to study and be able to advance my C
programming skills. Do you recomend any open source project in
particular that in your opinion has good writen C code? Thanks.


Here's my open source "toolbelt" of code:

http://www.ioplex.com/~miallen/libmba/dl/src/

Regarding it's quality; most of the modules are ANSI C so other than that
quality is a matter of opinion. Or it depends on what you're using the
code for. Condsider the stack.c module for example. It was developed with
the assistance of people on this newsgroup several years ago and helped
define my style. However it is a general purpose ADT that automatically
grows and shrinks as memory requirements change. It also checks parameters
and sets errno. These are things that would not be appropriate in some
cases. Some simple PUSH/POP macros would certainly be more efficient.

Mike
Nov 14 '05 #13

P: n/a
Sidney Cadot wrote:
Richard Heathfield wrote:
[snip]


A rather funny thought just occurred to me: what would happen if
people of this caliber got together to work on a real-life project?
Seems that a mediocre outcome is out of the question... Either the
result would be quite brilliant or a total deadlock, I think :-)


The book "C Unleashed", by Heathfield et al, is a fairly recent
example.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 14 '05 #14

P: n/a


Richard Heathfield wrote:
Peter Nilsson wrote:

But more critically, a group considering a project that would actually
_need_ more than two (say) genuine C _experts_ should probably
reconsider it's choice of programming language! ;)

Or perhaps a group that thinks it can get away with using non-experts should
be designing street-signs instead of software.


In at least some applications, and I'd suspect most, the benefits of C
expertise are a drop in ocean compared to expertise in the domain that's
using C.

Given the choice of a domain expert with limitted C knowledge and a C
expert with limitted domain knowledge, I'd certainly choose the domain
expert.

Ed.

Nov 14 '05 #15

P: n/a
Ed Morton wrote:


Richard Heathfield wrote:
Peter Nilsson wrote:

But more critically, a group considering a project that would actually
_need_ more than two (say) genuine C _experts_ should probably
reconsider it's choice of programming language! ;)

Or perhaps a group that thinks it can get away with using non-experts
should be designing street-signs instead of software.


In at least some applications, and I'd suspect most, the benefits of C
expertise are a drop in ocean compared to expertise in the domain that's
using C.

Given the choice of a domain expert with limitted C knowledge and a C
expert with limitted domain knowledge, I'd certainly choose the domain
expert.


Frankly, given the same choice, so would I - and I might even consider
switching the project language to that favoured by the domain expert.

Interestingly, in most of /my/ programming career, the critical domain has
been C itself.

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 14 '05 #16

P: n/a
On Sat, 27 Dec 2003 22:09:10 -0600, in comp.lang.c , Ed Morton
<mo****@lsupcaemnt.com> wrote:


Richard Heathfield wrote:

Or perhaps a group that thinks it can get away with using non-experts should
be designing street-signs instead of software.


Given the choice of a domain expert with limitted C knowledge and a C
expert with limitted domain knowledge, I'd certainly choose the domain
expert.


Hmm. Sounds like a microsoftian saying, or do you work in Dilbert's
office? :-)

Lets face it, if you had a choice of either one or the other, your
project is already doomed. You don't know enough C to write hte
programme well, or you don't know enough about your requirements
domain to design it in the first place... argh.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 14 '05 #17

P: n/a
Mark McIntyre wrote:
Ed Morton wrote:
Richard Heathfield wrote:

Or perhaps a group that thinks it can get away with using non-experts
should be designing street-signs instead of software.


Given the choice of a domain expert with limitted C knowledge and a C
expert with limitted domain knowledge, I'd certainly choose the domain
expert.


Hmm. Sounds like a microsoftian saying, or do you work in Dilbert's
office? :-)

Lets face it, if you had a choice of either one or the other, your
project is already doomed. You don't know enough C to write hte
programme well, or you don't know enough about your requirements
domain to design it in the first place... argh.


It doesn't have to be that stark a choice. Expertise is not a Boolean
concept. It is possible to know enough about a domain to do useful work in
it without necessarily being an expert in that domain, as long as real
expertise is somehow available to you when required (co-worker, good book,
whatever). Similarly, it is possible to know enough about C to do useful
work in it without necessarily being a C expert.

If you're good at picking your team, you'll have C experts AND domain
experts, who will learn from each other as the project progresses.

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 14 '05 #18

P: n/a
"Peter Nilsson" <ai***@acay.com.au> wrote in message
news:3f********@news.rivernet.com.au...
But more critically, a group considering a project that would actually
_need_
more than two (say) genuine C _experts_ should probably reconsider it's
choice
of programming language! ;)


Something just occurred to me. Suppose a group of C experts clc style would
start out to create a windows program with Win32 and C. I think they would
be stressed out in a matter of weeks :-)
Threads, writing to the registry, shoving windows around, dll's, that's not
portable!
_stdcall, _cdecl, casting longs to function pointers, WPARAM to CREATESTRUCT
* and a second time to int, oh my!
Nov 14 '05 #19

P: n/a

"Servé Lau" <i@bleat.nospam.com> wrote in message news:bs**********@news2.tilbu1.nb.home.nl...
"Peter Nilsson" <ai***@acay.com.au> wrote in message
news:3f********@news.rivernet.com.au...
But more critically, a group considering a project that would actually
_need_
more than two (say) genuine C _experts_ should probably reconsider it's
choice
of programming language! ;)


Something just occurred to me. Suppose a group of C experts clc style would
start out to create a windows program with Win32 and C. I think they would
be stressed out in a matter of weeks :-)
Threads, writing to the registry, shoving windows around, dll's, that's not
portable!
_stdcall, _cdecl, casting longs to function pointers, WPARAM to CREATESTRUCT
* and a second time to int, oh my!


More likely they would keep separate the platform-specific and
non-portable code from "official clc-approved ISO Standard C" code.

That way, when they, or their successors in eighteen months time,
come to port the program to a different platform or simply just
a different compiler or graphics library, it would be obvious
which parts need to be changed and which do not.

And after the port, they'd still have the portable, standard bit,
but now there would be two different (non-portable) modules
interfacing to two different platforms or databases or window
systems or whatever.

But, not being an expert, I'm just guessing. :-)

John.
Nov 14 '05 #20

P: n/a


Mark McIntyre wrote:
On Sat, 27 Dec 2003 22:09:10 -0600, in comp.lang.c , Ed Morton
<mo****@lsupcaemnt.com> wrote:


Richard Heathfield wrote:
Or perhaps a group that thinks it can get away with using non-experts should
be designing street-signs instead of software.
Given the choice of a domain expert with limitted C knowledge and a C
expert with limitted domain knowledge, I'd certainly choose the domain
expert.

Hmm. Sounds like a microsoftian saying, or do you work in Dilbert's
office? :-)


That would certainly explain a few things around here...
Lets face it, if you had a choice of either one or the other, your
project is already doomed. You don't know enough C to write hte
programme well, or you don't know enough about your requirements
domain to design it in the first place... argh.


We typically have many domain experts (who know C well enough to get by,
but aren't experts) and a few C experts (who may or may not know the
specific application domain) to answer the tricky questions and that
seems to work out pretty well.

Ed.

Nov 14 '05 #21

This discussion thread is closed

Replies have been disabled for this discussion.