今天看了一下main的初步源码,第一行,就让我学到了一些东西
int ngx_cdecl
main(int argc, char *const *argv)
什么是ngx_cdecl
找到
#define ngx_cdecl
是个空定义,那么究竟是来干嘛的
查了一下,发现是跨平台时的一种约定。
http://en.wikipedia.org/wiki/X86_calling_conventions
简单来说,就是在不同的平台上,要遵守特定的标准,为了避免平台不同导致出的程序异常,在使用到平台特定的编译时,需要制定惯例
| cdecl | GCC | RTL (C) | Caller | When returning struct/class, the calling code allocates space and passes a pointer to this space via a hidden parameter on the stack. The called function writes the return value to this address. | |
| cdecl | Microsoft | RTL (C) | Caller | When returning struct/class,
| |
上面的解释显然体现了两个不同平台的处理
MS只有在非POD情况下,才和GCC一样
POD:
将对象的各字节拷贝到一个字节数组中,然后再将它重新拷贝到原先的对象所占的存储区中,此时该对象应该具有它原来的值。

449

被折叠的 条评论
为什么被折叠?



