touch XX.h; cpp -dM XX.h

pengxn 2010-10-25 09:17:21
touch XX.h; cpp -dM XX.h

求这个命令的详细解释
...全文
126 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
steptodream 2010-10-26
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 bluejays 的回复:]

要察看所有预定义宏,可以直接这样:
cpp -dM /dev/null
[/Quote]
他那是AIX 上面都提示不支持dM选项了 你还告诉他这样 晕
bluejays 2010-10-25
  • 打赏
  • 举报
回复
LZ的cpp是什么版本?用这个命令看一下
cpp --version
bluejays 2010-10-25
  • 打赏
  • 举报
回复
要察看所有预定义宏,可以直接这样:
cpp -dM /dev/null
bluejays 2010-10-25
  • 打赏
  • 举报
回复
touch XX.h 如果XX.h原来不存在,就创建一个名为XX.h的0字节的空文件;如果XX.h原来就存在,就把它的时间(就是用ls -l看到的时间)改成当前时间。

cpp 不是通常以为的c++,而是gcc里面的预处理器(c PreProcessor),他的作用是处理#include还有#define这些预处理指令
steptodream 2010-10-25
  • 打赏
  • 举报
回复
关于xlc的预定义宏 在下面这本书的第五章讲了
http://www.roe.ac.uk/~ert/IBM/PDFs/xlc-manual.pdf
jihen 2010-10-25
  • 打赏
  • 举报
回复
顶熊猫大哥
steptodream 2010-10-25
  • 打赏
  • 举报
回复
这是AIX下cpp命令的详解 似乎可选参数不入linux下的cpp命令多
http://www.kuqin.com/aixcmds/aixcmds1/cpp.htm

steptodream 2010-10-25
  • 打赏
  • 举报
回复
你man cpp一下啊 貌似你的系统里cpp 不支持dM参数
我是在linux里测试的 所有的软件和命令都属于GNU
pengxn 2010-10-25
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 steptodream 的回复:]
摘自man cpp其中一段

C/C++ code

-dCHARS
CHARS is a sequence of one or more of the following characters, and
must not be preceded by a space. Other characters are interpreted
……
[/Quote]

$ cpp -dM foo.h
1506-173 (W) Option dM is not valid. Enter xlc for list of valid options.
#line 1 "foo.h"

奇怪我总报错,知道xlC应该用什么参数吗
steptodream 2010-10-25
  • 打赏
  • 举报
回复
摘自man cpp其中一段

-dCHARS
CHARS is a sequence of one or more of the following characters, and
must not be preceded by a space. Other characters are interpreted
by the compiler proper, or reserved for future versions of GCC, and
so are silently ignored. If you specify characters whose behavior
conflicts, the result is undefined.

M Instead of the normal output, generate a list of #define direc-
tives for all the macros defined during the execution of the
preprocessor, including predefined macros. This gives you a
way of finding out what is predefined in your version of the
preprocessor. Assuming you have no file foo.h, the command

touch foo.h; cpp -dM foo.h

will show all the predefined macros.

steptodream 2010-10-25
  • 打赏
  • 举报
回复
touch foo.h
cpp -dM foo.h

第一句是创建一个foo.h文件
  第二句 所有的预定义宏(predefined macros)都会被打印出来。比如LINUX系统上的cpp定义了__linux__宏,而Mac OS X上的cpp则定义了__APPLE__宏,这个是判断操作系统类型的一个简单方法。

23,114

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧