[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gEDA-user: gEDA programming



On Fri, 2010-04-23 at 13:00 +0200, Miguel SÃnchez de LeÃn Peque wrote:
> Hi all,
>    I'm a student interested in contributing to gEDA and learn some C ;-).
>    The biggest problem I find any time I start coding is "how should I
>    write this?". You're always talking about deprecated code, libraries
>    you're/you're not using, old style...
>    Could you tell me any book/reference you'd find necessary to learn
>    modern C programming? Or to learn how to use extended libraries as GTK
>    and glibc? Or any other library widely used in C programming... Maybe
>    there's no book for that, it's just programming experience... am I
>    right? (I hope not! xD)
>    Thanks in advance,

>    A student who is a bit confused about which is good modern C
>    programming style... :-)

I think the trick is to use rich APIs such as GLib - rather than
exclusively using the string.h, stdlib.h stuff provided in the C
standard.

The GLib routines take care of a lot of memory management relating to
strings, and make like a lot easier (and the code more readable). There
is nothing worse than an "optimised" parser looping over memory with
constructs like if (*i++ == '(') ... or some such.

White-space etc.. is just a matter of style, and you'll have to watch
the more recent commits into the project to pick up what is usual there.
When making minor edits in existing code, stick with what is already
there. For new routines.. try to be consistent with the code others are
adding. (Which roughly matches the Gnome / GTK / GLib coding styles,
although we _don't_ tend to use tabs anywhere.

Deprecated APIs.. you will need to look up the references for the
libraries you're coding with. "devhelp" provides a nice view of these
for GTK, GLib and various others. The documentation for the routines
lists whether they are deprecated or not.

As for books.. I've no idea, I (think) I learned by reading existing
code examples and playing around!

-- 
Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA

Tel: +44 (0)7729 980173 - (No signal in the lab!)
Tel: +44 (0)1223 748328 - (Shared lab phone, ask for me)



_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user