227 | | typical structure of *.c file |
| 227 | === Headers === |
| 228 | |
| 229 | Do not mix headers |
| 230 | |
| 231 | '''This is right:''' |
| 232 | {{{ |
| 233 | |
| 234 | #include <errno.h> |
| 235 | #include <stdio.h> |
| 236 | #include <string.h> |
| 237 | |
| 238 | #include <sys/types.h> |
| 239 | #include <sys/stat.h> |
| 240 | |
| 241 | #include "lib/global.h" |
| 242 | #include "lib/tty/tty.h" /* LINES, tty_touch_screen() */ |
| 243 | #include "lib/tty/win.h" /* do_enter_ca_mode() */ |
| 244 | |
| 245 | #include "src/subshell.h" /* use_subshell */ |
| 246 | #include "src/help.h" /* interactive_display() */ |
| 247 | #include "src/setup.h" |
| 248 | |
| 249 | }}} |
| 250 | |
| 251 | '''This is wrong:''' |
| 252 | {{{ |
| 253 | #include <errno.h> |
| 254 | #include <sys/types.h> |
| 255 | #include <stdio.h> |
| 256 | #include <string.h> |
| 257 | |
| 258 | #include <sys/stat.h> |
| 259 | |
| 260 | #include "src/subshell.h" /* use_subshell */ |
| 261 | #include "src/help.h" /* interactive_display() */ |
| 262 | |
| 263 | #include "lib/tty/tty.h" /* LINES, tty_touch_screen() */ |
| 264 | #include "lib/tty/win.h" /* do_enter_ca_mode() */ |
| 265 | |
| 266 | #include "src/setup.h" |
| 267 | #include "lib/global.h" |
| 268 | |
| 269 | }}} |
| 270 | |
| 271 | Use short comment for header file |
| 272 | |
| 273 | '''This is right:''' |
| 274 | {{{ |
| 275 | #include "lib/tty/tty.h" /* LINES, tty_touch_screen() */ |
| 276 | #include "lib/tty/win.h" /* do_enter_ca_mode() */ |
| 277 | #include "src/subshell.h" /* use_subshell */ |
| 278 | #include "src/help.h" /* interactive_display() */ |
| 279 | |
| 280 | }}} |
| 281 | |
| 282 | Do not mix global and local variables and functions. |
| 283 | Do not mix static and non-static statments. |
| 284 | |
| 285 | Follow typical structure of *.c file: |