Skip to content

Instantly share code, notes, and snippets.

@Akagi201
Created April 28, 2014 07:32
Show Gist options
  • Save Akagi201/705cb76bf550a1b22a26 to your computer and use it in GitHub Desktop.
Save Akagi201/705cb76bf550a1b22a26 to your computer and use it in GitHub Desktop.

项目分类

  • library
  • standalone application

standalone application

目录结构

原则是目录层次尽可能的低, 文件与目录数量尽可能的少, 如果源码比较少, 可以不用src目录, .c/.cpp直接放到项目根目录下.

project/
 |-- Makefile
 |
 |-- doc/
 |
 |-- example/
 |
 |-- include/
 |    |-- *.h
 |    |-- *.hpp
 |
 |-- lib/
 |    |-- *.a
 |    |-- *.so
 |
 |-- zlog/
 |
 |-- libpcap/
 |
 |-- libnids/
 |
 |-- libcrypto/
 |
 |-- zlib/
 |
 |-- src/

文件中函数的顺序

  • 越基础, 被用到的越多, 越底层的函数排列的顺序越靠前.

Makefile

  • 越往上是越需要修改的. 把容易修改的放在上面, 基本不变的放在下面.

代码风格

  • Astyle
  • Doxygen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment