什么是#pragma?
来源:互联网 发布:js toggle 切换状态 编辑:程序博客网 时间:2024/06/06 05:58
#pragma指令可以用于实现相关的控制与扩展: 源码表控制, 结构压缩, 以及警告去除等等。
一些头文件中, 有#pragma once, 其实和#ifndef技巧等价, 可以避免所在的文件在一个单独编译中只包含一次。 比#ifndef的好处就是拥有较少的代码, 避免名称到碰撞。
例如下面:
- grandparent.h
#pragma once struct foo { int member;};
- parent.h
#include "grandparent.h"
- child.c
#include "grandparent.h"#include "parent.h"
另外, 使用#pragma pack(push(n))可以进行结构体的对齐设置, 参见之前写的关于struct包含的字节问题的博客。
0 0
- 什么是#pragma?
- #pragma
- Pragma
- #pragma
- #pragma
- #pragma
- #pragma
- #pragma
- #pragma
- #pragma
- #pragma
- #pragma
- #pragma
- #pragma
- #pragma
- #pragma
- #pragma
- #pragma
- 地址空间
- 位域的使用
- C++强制类型转换
- hdu 1010 Tempter of the Bone
- 扑克序列——第五届蓝桥杯省赛C语言A组第6题
- 什么是#pragma?
- 图像验证码识别(六)——图像中的直线检测
- CGI, FCGI, SCGI, WSGI 释异
- 编程小技巧
- Ash数学运算
- tomcat的配置
- Git安装与配置
- ironic multi conductors realization
- Common Lisp的值类型及SBCL中的底层表示