GNU C 编译器内部/GCC 黑客 3 4
外观
	
	
为每个结构添加 toString() 方法,如 Java
[编辑源代码]从函数中调用代码块,如 Ruby
[编辑源代码]Linux 中的列表实现允许在列表的每个元素上调用代码块
       list_for_each_prev(pos, head) {
                struct nfs_page *p = nfs_list_entry(pos);
                if (page_index(p->wb_page) < pg_idx)
                        break;
       }
list_for_each_prev 将代码块作为参数。诀窍是使用一个宏,它展开为一个 for() 循环,循环体成为代码块。这个项目的目的是允许程序员在函数调用中使用代码块。
在返回结构体时解除引用函数结果
[编辑源代码]C 允许在函数返回值是指向结构体的指针时解除引用返回值
get_struct()->field=0;
如果函数返回的是结构体本身,而不是指向它的指针,则会生成编译时错误
get_struct().field=0; > request for member `field' in something not a structure or union
此扩展解决了解除引用作为返回值的结构体的问题。
使用函数初始化变量
[编辑源代码]当定义和初始化变量时,初始化器是常量。如果尝试使用函数,无论该函数是什么,都会出现错误
 int getint() { return 1; }
 int i=getint();
 > initializer element is not constant
当使用变量时,会调用用于初始化它的函数。
函数参数的默认值,如 C++
[编辑源代码] void func(int a=0) {
   printf("a=%d\n", a);
 }
 int main() {
   func();
 }
 > syntax error before '=' token
引用参数,如 C++
[编辑源代码]void test(int &a, int &b); int x,y; test(x,y);
目标文件中的 GCC 开关
[编辑源代码]目标文件中的 GCC 开关用法:/usr/local/bin/paster serve [选项] CONFIG_FILE [start|stop|restart|status] 服务所描述的应用程序
如果给出 start/stop/restart,则将启动(正常运行)、停止(--stop-daemon)或执行两者。您可能还需要 ``--daemon`` 来停止。
选项
 -h, --help            show this help message and exit
 -v, --verbose
 -q, --quiet
 -nNAME, --app-name=NAME
                       Load the named application (default main)
 -sSERVER_TYPE, --server=SERVER_TYPE
                       Use the named server.
 --server-name=SECTION_NAME
                       Use the named server as defined in the configuration
                       file (default: main)
 --daemon              Run in daemon (background) mode
 --pid-file=FILENAME   Save PID to file (default to paster.pid if running in
                       daemon mode)
 --log-file=LOG_FILE   Save output to the given log file (redirects stdout)
 --reload              Use auto-restart file monitor
 --reload-interval=RELOAD_INTERVAL
                       Seconds between checking files (low number can cause
                       significant CPU usage)
 --status              Show the status of the (presumably daemonized) server
 --user=USERNAME       Set the user (usually only possible when run as root)
 --group=GROUP         Set the group (usually only possible when run as root)
 --stop-daemon         Stop a daemonized server (given a PID file, or default
                       paster.pid file)
[app:main] use = egg:PasteEnabledPackage option1 = foo option2 = bar
[server:main] use = egg:PasteScript#wsgiutils host = 127.0.0.1 port = 80 sudo update-rc.d startup.sh defaults
运行时的类型信息
[编辑源代码]C 语言在运行时没有类型信息。这个想法是允许程序在运行时获取结构体字段的名称和偏移量、枚举声明的符号名称等。例如,代替编写
  enum tree_code code;
  ...
  switch (code) {
    case VAR_DECL:
      printf("VAR_DECL\n");
      break;
    case BLOCK:
      printf("BLOCK\n");
      break;
    ...
  }
可以编写
  printf("%s\n", type_info(code).name);