Presentation is loading. Please wait.

Presentation is loading. Please wait.

GNU Coding Guidelines Shakthi Kannan GNU Free Documentation License

Similar presentations


Presentation on theme: "GNU Coding Guidelines Shakthi Kannan GNU Free Documentation License"— Presentation transcript:

1 GNU Coding Guidelines Shakthi Kannan GNU Free Documentation License
October 2007 Version 1.0

2 How to use the GPL /* * main.c * * The main file of the program
* Copyright (C) 2007 Shakthi Kannan * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA USA. */

3 Clean-up temporary files.
Check $TMPDIR. Else use /tmp. Clean-up temporary files.

4 Error messages Interactive programs Non-interactive programs
program : message program : source-file-name : lineno : message program : source-file-name : lineno : column : message Interactive programs source-file-name: lineno-1-lineno-2: message source-file-name: lineno-1.column-1-column-2: message source-file-name: lineno-1.column-1-lineno-2.column-2: message

5 Comments /* So, you can comment? */ /* * You can pass more comments?

6 Naming Use lowercase only for variables. int pencil;
Separate names with underscore: int return_my_pencil; Use all CAPS for constants. #define JAMES_BOND 007

7 Functions Check return values. Example: malloc () system calls

8 Function declaration void add_to_list (char *buf, char *rbuf);
char *gamma (char *buf); int run_test (struct gnc *x);

9 C function parentheses
/* the main function */ int main (int argc, char *argv[]) { }

10 Long function arguments
void select_team (char *players, int advertising, int eleven) { /* do nothing */ }

11 if-else constructs if (you_sleep) { printf (“Good”); } else
printf (“You're awake!”);

12 do-while constructs do { /* speak the truth */ } while (true);

13 Splitting long expressions
split before operator if (bored_life && dull_friends && remaining_conditions) { /* cheer up! */ }

14 Internationalization
Use GNU gettext file.c printf (_(“%s, never take life seriously. Nobody gets out alive, anyway\n” your_name); file.pot msgid “%s, never take life seriously. Nobody gets out alive, anyway\n” msgstr “”

15 ChangeLog 2006-02-07 Matthew Allum <mallum@openedhand.com>
* applets/mb-applet-system-monitor.c: (system_memory), (main): * configure.ac: Detect kernel version at run rather than build time. Matthew Allum * src/msg.c: (_get_server_time), (msg_win_create), (msg_handle_events), (msg_calc_win_size): * src/panel.c: (panel_main): * src/session.c: (session_preexisting_clear_current): * src/session.h: Apply patch from Phil Blundell remove uneeded polling. ( See bug #68 )

16 README README ===== Greetings!
The directory contains simple Linux device driver code examples, for character device operations. The device drivers are for 2.6 kernels. The code examples include: ex1-hello-world/ ex2-init-exit/ ex3-doc-license/ ex4-param/ ex5-multi-file/ ex6-char-register/ ex7-char-dev-register/ ex8-char-dev-register-dynamic/ ex9-write/ ex10-read/ ex11-debug/ ex12-proc/ ex13-ioctl

17 References Richard Stallman. September 23, 2007. GNU Coding Standards.
Gary V. Vaughan, Ben Elliston, Tom Tromey, and Ian Lance Taylor. February 8, GNU Autoconf, Automake, and Libtool.


Download ppt "GNU Coding Guidelines Shakthi Kannan GNU Free Documentation License"

Similar presentations


Ads by Google