Five little suggestions for working on GNOME libraries

The GNOME OPW for Summer 2012 is approaching to the end. By working with the code of GUPnP through the internship, I have learned a lot about C programming with GLib/GObject. I think it is a great time to share some from what I learned to everyone, especially the beginners.

Here I collect five small suggestions focusing on coding:

  1. Avoid the trailing white space in your code and patch. Set your editor to be aware of the unnecessary white spaces at the end of line. Git doesn’t like them nor your mentor. If you use Vim, you can look at this page.

  2. Use --enable-shared=no during the configure phase to disable the build of shared library. This makes the test programs under tests directory statically linked to the target library. Otherwise the test programs will be Bash wrapper scripts. Doing so make it easier when you use gdb to load the test programs.

  3. Use CFLAGS=-g in the configure phase to generate the debugging info. Even though you may find configure --help shows you an option called --enable-debug, it basically will convert to -g -O3 for gcc. This -O3 will optimize your code and make it hard to track the execution in gdb.

  4. Combine your local commits into a single patch. After finishing a specific feature or fixing a particular bug, you may have many local commits in your Git commit tree. You may also have merges from the upstream repository. I find this link is extremely helpful to form a single patch from the mess.

  5. Use DevHelp. Even though you might prefer to the online documentation, you should give DevHelp a try. It is more convenient and faster. It can only show the documentation you are interested.

All right. That is it. Hopefully you will find them helpful.