imacros命令
Asterisk CLI 命令列表

以下的命令是在CLI控制台上用help命令列出的集合:!: 执行一个shell command用法:!<command>说明:执行一个shell命令abort halt: 取消一个暂停用法:abort shutdown说明:让Asterisk放弃一个正在执行的shutdown或者restart,正常继续运行呼叫操作add extension: 增加新的extension到context用法:add extension <exten>,<priority>,<app>,<app-data> into <context> [replace]说明:这个命令会增加一个新的extension到<context>。
如果已经有了同样的priority的extension‘,最后的replace’参数可以替代这个extension例子:add extension 6123,1,Dial,IAX/216.207.245.56/6123 into local现在,你可以拨打6123,并且和Markster交谈了。
add ignorepat:增加新的匹配模式用法:add ignorepat <pattern> into <context>说明:这个命令增加一个新的匹配模式到context <context>例子:add ignorepat _3XX into localadd queue member: 向指定的队列增加一个通道用法:add queue member <channel> to <queue> [penalty <penalty>]说明:向一个队列增加一个通道成员,[penalty <penalty>]指明这个通道成员的优先级ael debug contexts:启用AEL contexts调试ael debug macros:启用AEL macros调试ael debug read:启用AEL read调试ael debug tokens:启用AEL tokens调试ael no debug:关闭AEL调试信息ael reload:重载AEL配置agent logoff:让一个座席离线用法:agent logoff <channel> [soft]说明:让一个座席不在登录进来,如果指定了soft选项,不会强行挂机退出通话agi debug:启用AGI调试用法:agi debug说明:启用为调试目的而将AGI传输的内容输出agi no debug:关闭AGI调试用法:agi no debug说明:关闭为调试目的而将AGI传输的内容输出到控制台cb mysql status:显示CBMySQL的连接状态信息用法:cb mysql status说明:列出当前CBMySQL的mysql连接状态结果例子:Connected to conference@localhost, port 3306 with username mvb2000user for 6 days, 10 hours, 11 minutes, 40 seconds.Wrote 0 records since last restart.cdr mysql status:显示cdr_mysql的连接状态信息用法:cdr mysql status说明:显示cdr_mysql的当前连接状态例子:Connected to mvb2000cdrdb@localhost, port 3306 using table cdr for 6 days, 10 hours, 14 minutes, 46 seconds.Wrote 7 records since last restart.cdr status:Display the CDR status用法:cdr status说明:显示通话详细记录引擎的系统状态例子:CDR logging: enabledCDR mode: simpleCDR registered backend: csvCDR registered backend: mysqlCDR registered backend: cdr_managerdatabase del:删除数据库的key/value用法:database del <family> <key>说明:删除Asterisk数据库中指定的family和key的记录database deltree: Removes database keytree/values用法:database deltree <family> [keytree]说明:在Asterisk数据库中删除一个family或者指定的在family中的keytreedatabase get: Gets database value用法:database get <family> <key>说明:在Asterisk数据库中为指定的family和key检索记录database put: Adds/updates database value用法:database put <family> <key> <value>说明:在asterisk数据库中以指定的famliy、key、value新增或者修改一个记录database show显示数据库内容用法:database show [family [keytree]]说明:显示Asterisk数据库的内容,可选的关联一个指定的family或者family和keytreedatabase showkey显示数据库内容用法:database showkey <keytree>说明:显示Asterisk数据库内容,关联到指定的keydebug channel:启用在一个通道上的调试信息用法:debug channel <channel>说明:在指定的通道上打开调试信息debug level:设置全局调试信息的等级用法:debug level <level> [filename]说明:设置调试为指定的等级(0为关闭调试)。
GCC使用说明

GCC使用手册及常用命令行GCC使用手册作者:Clock1.前言GCC编译器的手册(GCC MANUAL)的英文版已经非常全面,并且结构也非常完善了,只是一直都没有中文的版本,我这次阅读了GCC编译器的主要内容,对手册的内容进行了结构性的了解,认为有必要对这次阅读的内容进行整理,为以后的工作做准备。
由于我对这个英文手册的阅读也仅仅是结构性的。
因此有很多地方并没有看,所以这篇文档的内容我也只能写出部分,对于以后需要详细了解的地方,会再往这篇文档中增添内容,需要增添的内容主要是编译器的各种开关。
2. GCC功能介绍GCC编译器完成从C、C++、objective-C等源文件向运行在特定CPU硬件上的目标代码的转换(这是任何一个编译器需要完成的任务)。
GCC能够处理的源文件分为C、C++、Objective-C、汇编语言等。
对于这些源文件,用他们的后缀名进行标示。
GCC能够处理的后缀有:a. *.c *.C (C语言)b. *.cxx *.cc (C++语言)c. *.m (面向对象的C)d. *.i (预处理后的C语言源文件)e. *.ii (预处理后的C++语言源文件)f. *.s *.S (汇编语言)h. *.h (头文件)目标文件可以是:a. *.o 编译连接后的目标文件b. *.a 库文件编译器把编译生成目标代码的任务分为以下4步:a.预处理,把预处理命令扫描处理完毕;b.编译,把预处理后的结果编译成汇编或者目标模块;c.汇编,把编译出来的结果汇编成具体CPU上的目标代码模块;d.连接,把多个目标代码模块连接生成一个大的目标模块;3. GCC开关GCC的运行开关共分为11类,这是类开关从11个方面控制着GCC程序的运行,以达到特定的编译目的。
3.1. 全局开关(OVERALL OPTIONS)全局开关用来控制在“GCC功能介绍”中的GCC的4个步骤的运行,在缺省的情况下,这4个步骤都是要执行的,但是当给定一些全局开关后,这些步骤就会在某一步停止执行,这产生中间结果,例如可能你只是需要中间生成的预处理的结果或者是汇编文件(比如拟的目的是为了看某个CPU上的汇编语言怎么写)。
宏指令使用说明

威纶通触摸屏宏指令使用说明一、 宏指令的结构一般为以下格式全局变量声明 ………………………………………………可选Sub Function Block Declarations(子函数声明)…………可选局部变数声明End Sub(结束子函数)macro_command main() [主函数]…………………………必须局部变数声明[各式语句]end macro_command [结束主函数] ……………………必须一个宏指令必须有一个且只有一个主函数,用来开始宏指令的执行。
格式为:macro_command函数名称()end macro_command双斜线"//" 代表程序批注,在它后面的文字不会被执行。
二、宏指令的语法常数:常数是一个可以被各式语句直接使用的固定的资料。
有如下格式:下面即为一个简单的常数使用的范例。
macro_command main()short A, B // 声明A 和B 为短整型变数A = 1234B = 0x12 // 1234 和0x12 即为常数end macro_command变数:变量是一个代表着各种资料的名称。
在宏指令中,这些资料可以随着宏指令语句执行的结果改变而改变。
必须以英文字母开头。
变量名称长度不超过32 个字符。
系统保留寄存器名称不能作为变量名称。
下面为8 种不同的变量类型,前5种为有号数值类型,后3种为无号数值类型:变数声明:变量必须在使用前声明。
所以,在宏指令,所有的变量都必须在语句使用前都被声明完成。
声明变量时,先定义变量的类型,后面再跟着变量名称。
如下范例:int ashortb, switchfloatpressureunsigned short c数组声明:宏指令支持一维数组(下标从0 开始)。
声明数组变量时,先定义数组变量的类型,变量名称,接着就是该数组变量的个数,变量个数必须放置在“““”符号中。
数组变量的长度为1 ~ 4096。
预处理器宏指令(Macro)

预处理器宏指令(Macro)预处理器宏指令(Macro)1 ⽬的:编译之前进⾏预处理,批量处理源代码⽂件(宏)2 原理:编译之前由编译器调⽤预处理器,批量处理源代码中的指定标志⽂本。
预处理器是⼀个专⽤于处理源代码⽂本的独⽴程序,由编译器调⽤。
应该尽量减少使⽤预处理命令,因为不同的编译器的命令不同。
3 ⽅法:宏⼀般使⽤⼤写标识,以区别常规代码。
应该尽量减少宏的使⽤。
3.1.1定义替换标志:#define NAME VALUE,value只能是⼀个字符串,如果多于⼀⾏,则⽤\换⾏。
⽰例:#define APPTYPE 2qDebug()<<"APPTYPE="<<APPTYPE;3.1.2取消替换标志:#undef NAME。
3.1.3替换为字符串:在#define的参数中,如果使⽤#,则将参数替换为字符串。
⽰例:结果: max: hello world3.1.4连接参数:在#define的参数中,如果使⽤##,则将前后两个操作符连接为⼀个操作符。
结果:max: helloworld3.2 条件编译:#if…#elif…#else…#endif, #ifdef,#ifndef。
3.2.1数值条件判断:#if…#elif…#else…#endif。
⽐较数值,可以使⽤C的逻辑运算。
可以嵌套。
不能直接⽐较字符串。
⽰例:#if(APPTYPE==1)//cmdint iRst =gutang::cmdcore::QtCmdCore::processCmd (argc,argv);return iRst;#elif(APPTYPE==2)//server cmdqDebug()<<"APPTYPE="<<APPTYPE;int iRst =gutang::cmdcore::QtCmdCore::processCmd (argc,argv);gutang::cmdcore::QtCmdCore::processInput();return iRst;#else //guiQHash<QString,QString> hashArgv =gutang::cmdcore::QtCmdCore::parseCmd (argc,argv); MainWindow w(hashArgv);w.show ();#endif3.2.2定义与否判断:defined(NAME),ifdef判断宏名称是否已经定义。
imacros教程JS调用imacros所用到的函数

imacros教程(二):JS调用imacros所用到的函数
JS调用imacros所用到的函数
一、iimPlay() : 调用一个iim脚本。
完整调用方法为 : int ret_code = iimPlay ( String macro [, int timeout] ) ,返回值ret_code为1时说明iim被正确调用。
小于0则说明执行脚本时出现了错误,
履行 iMacros 的脚本语句,语句可以是一段,必须以 CODE: 起头,行间要用“\n” 分隔,返回值为负数代表履行有错
二、iimSet() :设置自定义变量
语法为:int ret_code = iimSet ( String -var_VARNAME, String VARVALUE )
最主要的就是上面两个,还可以了解一下
iimDisplay(msg):以独立对话框形式显示一个消息
string=iimGetLastExtract([n]) :返回第n此从页面里通过Extract得到的数据
iimGetLastError() 返回最近差错对应的差错信息(字符串)
Tag 未找到时会默认会等候 !TIMEOUT /10 这么常光阴,默认值就是 6 秒
分享到:。
mobaxterm的macros用法

mobaxterm的macros用法
Mobaxterm 是一款强大的终端模拟器,内置了一个 Cygwin,支持很多基本的常用的Linux 命令,比如 awk,cat,grep,find,tar,history 等。
其中,Macros 是Mobaxterm 中的一个功能,它可以帮助用户快速执行一些常用的命令或操作。
以下是 Macros 的具体用法:
1. 打开 Mobaxterm 并连接到你的远程会话。
2. 在会话窗口的菜单栏找到“Macros”(或者使用快捷键“Ctrl+M”)。
3. 选择“Record a new macro”开始录制宏。
4. 在会话中执行你希望宏自动执行的命令和操作。
5. 完成后,返回到“Macros”菜单并选择“Stop recording”。
6. 给宏命令命名并保存。
7. 要使用宏,只需打开“Macros”菜单,然后选择你想要执行的宏命令即可。
此外,你还可以通过右击“Saved macros”列表中的宏来对其进行重命名或编辑。
如果当前版本不支持直接录制宏,你可以在“Macros”鼠标右键 Import macro 导入附件文件,然后根据自己的需要编辑更改常用的命令。
imacros使用教程与注意事项

imacros使用教程与注意事项对于一些简单的重复操作,可以利用imacros来执行。
这里分享一些简单的教程和注意事项工具/原料•firefox浏览器或chrome浏览器•imacors 插件macros教程(一):imacros变量1.1imacros能记录你在网页中的动作,然后模拟你的动作自动重复执行。
进阶应用主要在于两个方面:1.用JS动态调用,重复执行之。
2.调用CSV文件,这个不错哦(还可以调用数据库,这个没用过。
)安装和火狐一般扩展安装方法一样,不会装的用google,安装后点击imacros的按钮,浏览器左边出现它的工作界面,就三部分:1.运行:(可以运行所存在的宏,不解释,别害怕很好用的)2.记录:(点记录即可记录你在网页中的动作,按停止即可自动保存为当前宏)3.编辑:(可以对存储的宏进一步编辑,更适合你的用途)imacros变量分为系统内定变量和用户自定义变量一、系统内定变量系统内定变量中有三个特殊的变量:VAR1 VAR2 VAR3 可以赋予任何值。
常见的系统内见变量:SET !VAR1 hello<sp>world设定!VAR1为 hello world (ps: <sp>代表空格<br>代表回车)SET !TIMEOUT 25 '宏超时值PROMPT Pleaseentertext !VAR1'弹出一个输入框,你在输入框中输入的内容将传到!VAR1中。
二、用户自定义变量:用户外部传入的变量iimSet(“myurl”,””)调用变量时用{{myurl}}2.2imacros教程(二):JS调用imacros所用到的函数JS调用imacros所用到的函数一、iimPlay() : 调用一个iim脚本。
完整调用方法为 : int ret_code = iimPlay ( String macro [, int timeout] ) ,返回值ret_code为1时说明iim被正确调用。
g++参数介绍

g++参数介绍[介绍]gcc and g++分别是gnu的c & c++编译器gcc/g++在执⾏编译⼯作的时候,总共需要4步1.预处理,⽣成.i的⽂件预处理器cpp2.将预处理后的⽂件不转换成汇编语⾔,⽣成⽂件.s编译器egcs3.有汇编变为⽬标代码(机器代码)⽣成.o的⽂件汇编器as4.连接⽬标代码,⽣成可执⾏程序连接器ld1.总体选项-E只激活预处理,这个不⽣成⽂件,你需要把它重定向到⼀个输出⽂件⾥⾯.例⼦⽤法:gcc -E hello.c > pianoapan.txtgcc -E hello.c | more慢慢看吧,⼀个hello word 也要与处理成800⾏的代码-S只激活预处理和编译,就是指把⽂件编译成为汇编代码。
例⼦⽤法gcc -S hello.c他将⽣成.s的汇编代码,你可以⽤⽂本编辑器察看-c只激活预处理,编译,和汇编,也就是他只把程序做成obj⽂件例⼦⽤法:gcc -c hello.c他将⽣成.o的obj⽂件2.⽬录选项-Idir在你是⽤#include"file"的时候,gcc/g++会先在当前⽬录查找你所制定的头⽂件,如果没有找到,他回到缺省的头⽂件⽬录找,如果使⽤-I制定了⽬录,他回先在你所制定的⽬录查找,然后再按常规的顺序去找.对于#include,gcc/g++会到-I制定的⽬录查找,查找不到,然后将到系统的缺省的头⽂件⽬录查找-include file-i相当于“#include”包含某个代码,简单来说,就是便以某个⽂件,需要另⼀个⽂件的时候,就可以⽤它设定,功能就相当于在代码中使⽤#include例⼦⽤法:gcc hello.c -include /root/pianopan.h-I-就是取消前⼀个参数的功能,所以⼀般在-Idir之后使⽤-idirafter dir在-I的⽬录⾥⾯查找失败,讲到这个⽬录⾥⾯查找.-iprefix prefix-iwithprefix dir⼀般⼀起使⽤,当-I的⽬录查找失败,会到prefix+dir下查找-Ldir制定编译的时候,搜索库的路径。
gcc命令大全

GCC 选项GCC 有超过100个的编译选项可用. 这些选项中的许多你可能永远都不会用到, 但一些主要的选项将会频繁用到. 很多的GCC 选项包括一个以上的字符. 因此你必须为每个选项指定各自的连字符, 并且就象大多数Linux 命令一样你不能在一个单独的连字符后跟一组选项. 例如, 下面的两个命令是不同的:gcc -p -g test.cgcc -pg test.c第一条命令告诉GCC 编译test.c 时为prof 命令建立剖析(profile)信息并且把调试信息加入到可执行的文件里. 第二条命令只告诉GCC 为gprof 命令建立剖析信息.当你不用任何选项编译一个程序时, GCC 将会建立(假定编译成功)一个名为a.out 的可执行文件. 例如, 下面的命令将在当前目录下产生一个叫a.out 的文件:gcc test.c你能用-o 编译选项来为将产生的可执行文件指定一个文件名来代替 a.out. 例如, 将一个叫count.c 的C 程序编译为名叫count 的可执行文件, 你将输入下面的命令:gcc -o count count.c注意: 当你使用-o 选项时, -o 后面必须跟一个文件名.-c 只编译并生成目标文件。
--------------------------------------------------------------------------------gcc and g++分别是gnu的c & c++编译器gcc/g++在执行编译工作的时候,总共需要4步1.预处理,生成.i的文件[预处理器cpp]2.将预处理后的文件不转换成汇编语言,生成文件.s[编译器egcs]3.有汇编变为目标代码(机器代码)生成.o的文件[汇编器as]4.连接目标代码,生成可执行程序[链接器ld][参数详解]-x language filename设定文件所使用的语言,使后缀名无效,对以后的多个有效.也就是根据约定C 语言的后缀名称是.c的,而C++的后缀名是.C或者.cpp,如果你很个性,决定你的C 代码文件的后缀名是.pig 哈哈,那你就要用这个参数,这个参数对他后面的文件名都起作用,除非到了下一个参数的使用。
iMacros使用进阶

iMacros使用进阶iMacros使用作者:zymaxsiMacros与js当你已经初步学会了如何使用iMacros后,为了实现更加复杂的操作,可以尝试使用用js来调用iMacros。
你可以在脚本中重命名一个.js后缀的脚本,之后运行该脚本将以js方式调用。
你也可以从外部载入一个js脚本,使用记录-载入或直接复制脚本到iMacros的Datasources目录第一次使用js调用iMacros脚本首先录制一个简单的脚本google.iimVERSION BUILD=6111213 RECORDER=FX'作者zymaxsTAB T=1URL GOTO=/TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:f ATTR=NAME:q CONTENT=iMacrosTAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:f ATTR=NAME:btnG&&VALUE:Google搜索录制完成后,再导入一个空文件,文件名为google.js。
编辑google.js:iimPlay("google");确定保存,然后运行这个文件运行刚刚的js我们发现,使用iimPlay可以方便的调用一个iim脚本。
iimPlay的完整调用方法为int ret_code = iimPlay ( String macro [, int timeout] )(备注:作者没有发现timeout的具体作用)返回值ret_code为1时说明iim被正确调用。
小于0则说明执行脚本时出现了错误如何调用外部参数在很多情况下,我们希望最终运行时输入的数据并不是录制的数据,而是需要自定义可修改的。
要达到这个使用目的可以使用iimSet()设置自定义变量-var_varname,然后在脚本中调用这个参数。
int ret_code = iimSet ( String -var_VARNAME, String VARVALUE )?调用示例修改google.js:iimSet ("-var_search","imacros")?iimPlay("google");修改google.iim中:CONTENT=Imacros 为CONTENT={{search}}再次运行google.js发现了吗,搜索传入的参数可以通过这种方式任意修改。
GNU C编译器 中文手册

GCC 中文手册GCCSection: GNU Tools (1)Updated: 2003/12/05Index Return to Main ContentsNAMEgcc,g++-GNU工程的C和C++编译器(egcs-1.1.2)总览(SYNOPSIS)gcc[option|filename ]...g++[option|filename ]...警告(WARNING)本手册页内容摘自GNU C编译器的完整文档,仅限于解释选项的含义.除非有人自愿维护,否则本手册页不再更新.如果发现手册页和软件之间有所矛盾,请查对Info文件, Info文件是权威文档.如果我们发觉本手册页的内容由于过时而导致明显的混乱和抱怨时,我们就停止发布它.不可能有其他选择,象更新Info文件同时更新man手册,因为其他维护GNU CC的工作没有留给我们时间做这个. GNU 工程认为man手册是过时产物,应该把时间用到别的地方.如果需要完整和最新的文档,请查阅Info文件`gcc’或Using and Porting GNU CC (for version 2.0) (使用和移植GNU CC 2.0) 手册.二者均来自Texinfo原文件 gcc.texinfo.描述(DESCRIPTION)C和C++编译器是集成的.他们都要用四个步骤中的一个或多个处理输入文件: 预处理(preprocessing),编译(compilation),汇编(assembly)和连接(linking).源文件后缀名标识源文件的语言,但是对编译器来说,后缀名控制着缺省设定:gcc认为预处理后的文件(.i)是C文件,并且设定C形式的连接.g++认为预处理后的文件(.i)是C++文件,并且设定C++形式的连接.源文件后缀名指出语言种类以及后期的操作:.c C源程序;预处理,编译,汇编.C C++源程序;预处理,编译,汇编.cc C++源程序;预处理,编译,汇编.cxx C++源程序;预处理,编译,汇编.m Objective-C源程序;预处理,编译,汇编.i 预处理后的C文件;编译,汇编.ii 预处理后的C++文件;编译,汇编.s 汇编语言源程序;汇编.S 汇编语言源程序;预处理,汇编.h 预处理器文件;通常不出现在命令行上其他后缀名的文件被传递给连接器(linker).通常包括:.o 目标文件(Object file).a 归档库文件(Archive file)除非使用了-c, -S,或-E选项(或者编译错误阻止了完整的过程),否则连接总是最后的步骤.在连接阶段中,所有对应于源程序的.o文件, -l库文件,无法识别的文件名(包括指定的 .o目标文件和.a库文件)按命令行中的顺序传递给连接器.选项(OPTIONS)选项必须分立给出: `-dr’完全不同于`-d -r ’.大多数`-f’和`-W’选项有两个相反的格式: -fname和 -fno-name (或-Wname和-Wno-name).这里只列举不是默认选项的格式.下面是所有选项的摘要,按类型分组,解释放在后面的章节中.总体选项(Overall Option)-c -S -E -o file -pipe -v -x language语言选项(Language Option)-ansi -fall-virtual -fcond-mismatch -fdollars-in-identifiers -fenum-int-equiv -fexternal-templates -fno-asm -fno-builtin -fhosted -fno-hosted -ffreestanding -fno-freestanding -fno-strict-prototype -fsigned-bitfields -fsigned-char -fthis-is-variable -funsigned-bitfields -funsigned-char -fwritable-strings -traditional -traditional-cpp -trigraphs警告选项(Warning Option)-fsyntax-only -pedantic -pedantic-errors -w -W -Wall -Waggregate-return -Wcast-align -Wcast-qual -Wchar-subscript -Wcomment -Wconversion -Wenum-clash -Werror -Wformat -Wid-clash-len -Wimplicit -Wimplicit-int -Wimplicit-function-declaration -Winline -Wlong-long -Wmain -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wno-import -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wshadow -Wstrict-prototypes -Wswitch -Wtemplate-debugging -Wtraditional -Wtrigraphs -Wuninitialized -Wunused -Wwrite-strings调试选项(Debugging Option)-a -dletters -fpretend-float -g -glevel -gcoff -gxcoff -gxcoff+ -gdwarf -gdwarf+ -gstabs -gstabs+ -ggdb -p -pg -save-temps -print-file-name=library -print-libgcc-file-name -print-prog-name=program优化选项(Optimization Option)-fcaller-saves -fcse-follow-jumps -fcse-skip-blocks -fdelayed-branch -felide-constructors -fexpensive-optimizations -ffast-math -ffloat-store -fforce-addr -fforce-mem -finline-functions -fkeep-inline-functions -fmemoize-lookups -fno-default-inline -fno-defer-pop -fno-function-cse -fno-inline -fno-peephole -fomit-frame-pointer -frerun-cse-after-loop -fschedule-insns -fschedule-insns2 -fstrength-reduce -fthread-jumps -funroll-all-loops -funroll-loops -O -O2 -O3预处理器选项(Preprocessor Option)-Aassertion -C -dD -dM -dN -Dmacro[=defn] -E -H -idirafter dir -include file -imacros file -iprefix file -iwithprefix dir -M -MD -MM -MMD -nostdinc -P -Umacro -undef汇编器选项(Assembler Option)-Wa,option连接器选项(Linker Option)-llibrary -nostartfiles -nostdlib -static -shared -symbolic -Xlinker option -Wl,option -u symbol目录选项(Directory Option)-Bprefix -Idir -I- -Ldir目标机选项(Target Option)-b machine -V version配置相关选项(Configuration Dependent Option)M680x0 选项-m68000 -m68020 -m68020-40 -m68030 -m68040 -m68881 -mbitfield -mc68000 -mc68020 -mfpa -mnobitfield -mrtd -mshort -msoft-floatVAX选项-mg -mgnu -munixSPARC选项-mepilogue -mfpu -mhard-float -mno-fpu -mno-epilogue -msoft-float -msparclite -mv8 -msupersparc -mcypressConvex选项-margcount -mc1 -mc2 -mnoargcountAMD29K选项-m29000 -m29050 -mbw -mdw -mkernel-registers -mlarge -mnbw -mnodw -msmall -mstack-check -muser-registersM88K选项-m88000 -m88100 -m88110 -mbig-pic -mcheck-zero-division -mhandle-large-shift -midentify-revision -mno-check-zero-division -mno-ocs-debug-info -mno-ocs-frame-position -mno-optimize-arg-area -mno-serialize-volatile -mno-underscores -mocs-debug-info -mocs-frame-position -moptimize-arg-area -mserialize-volatile -mshort-data-num -msvr3 -msvr4 -mtrap-large-shift -muse-div-instruction -mversion-03.00 -mwarn-passed-structsRS6000选项-mfp-in-toc -mno-fop-in-tocRT选项-mcall-lib-mul -mfp-arg-in-fpregs -mfp-arg-in-gregs -mfull-fp-blocks -mhc-struct-return -min-line-mul -mminimum-fp-blocks -mnohc-struct-returnMIPS选项-mcpu=cpu type -mips2 -mips3 -mint64 -mlong64 -mmips-as -mgas -mrnames -mno-rnames -mgpopt -mno-gpopt -mstats -mno-stats -mmemcpy -mno-memcpy -mno-mips-tfile -mmips-tfile -msoft-float -mhard-float -mabicalls -mno-abicalls -mhalf-pic -mno-half-pic -G num -nocppi386选项-m486 -mno-486 -msoft-float -mno-fp-ret-in-387HPPA选项-mpa-risc-1-0 -mpa-risc-1-1 -mkernel -mshared-libs -mno-shared-libs -mlong-calls -mdisable-fpregs -mdisable-indexing -mtrailing-coloni960选项-mcpu-type -mnumerics -msoft-float -mleaf-procedures -mno-leaf-procedures -mtail-call -mno-tail-call -mcomplex-addr -mno-complex-addr -mcode-align -mno-code-align -mic-compat -mic2.0-compat -mic3.0-compat -masm-compat -mintel-asm -mstrict-align -mno-strict-align -mold-align -mno-old-align DEC Alpha选项-mfp-regs -mno-fp-regs -mno-soft-float -msoft-floatSystem V选项-G -Qy -Qn -YP,paths -Ym,dir代码生成选项(Code Generation Option)-fcall-saved-reg -fcall-used-reg -ffixed-reg -finhibit-size-directive -fnonnull-objects -fno-common -fno-ident -fno-gnu-linker -fpcc-struct-return -fpic -fPIC -freg-struct-return -fshared-data -fshort-enums -fshort-double -fvolatile -fvolatile-global -fverbose-asm总体选项(Overall Option)-x language明确指出后面输入文件的语言为language (而不是从文件名后缀得到的默认选择).这个选项应用于后面所有的输入文件,直到遇着下一个`-x’选项. language的可选值有`c’, `objective-c’, `c-header’, `c++’, `cpp-output’, `assembler’,和`assembler-with-cpp’.-x none关闭任何对语种的明确说明,因此依据文件名后缀处理后面的文件(就象是从未使用过`-x’选项).如果只操作四个阶段(预处理,编译,汇编,连接)中的一部分,可以使用`-x’选项(或文件名后缀)告诉 gcc从哪里开始,用`-c’, `-S’,或`-E’选项告诉gcc到哪里结束.注意,某些选项组合(例如, `-x cpp-output -E’)使gcc不作任何事情.-c编译或汇编源文件,但是不作连接.编译器输出对应于源文件的目标文件.缺省情况下, GCC通过用`.o’替换源文件名后缀`.c’, `.i’, `.s’,等等,产生目标文件名.可以使用-o选项选择其他名字.GCC忽略-c选项后面任何无法识别的输入文件(他们不需要编译或汇编).-S编译后即停止,不进行汇编.对于每个输入的非汇编语言文件,输出文件是汇编语言文件.缺省情况下, GCC通过用`.o’替换源文件名后缀`.c’, `.i’,等等,产生目标文件名.可以使用-o选项选择其他名字.GCC忽略任何不需要编译的输入文件.-E预处理后即停止,不进行编译.预处理后的代码送往标准输出.GCC忽略任何不需要预处理的输入文件.-o file指定输出文件为file.该选项不在乎GCC产生什么输出,无论是可执行文件,目标文件,汇编文件还是预处理后的C代码.由于只能指定一个输出文件,因此编译多个输入文件时,使用`-o’选项没有意义,除非输出一个可执行文件.如果没有使用`-o’选项,默认的输出结果是:可执行文件为`a.out’, `source.suffix ’的目标文件是`source.o’,汇编文件是 `source.s’,而预处理后的C源代码送往标准输出.-v(在标准错误)显示执行编译阶段的命令.同时显示编译器驱动程序,预处理器,编译器的版本号.-pipe在编译过程的不同阶段间使用管道而非临时文件进行通信.这个选项在某些系统上无法工作,因为那些系统的汇编器不能从管道读取数据. GNU的汇编器没有这个问题.语言选项(LANGUAGE OPTIONS)下列选项控制编译器能够接受的C "方言":-ansi支持符合ANSI标准的C程序.这样就会关闭GNU C中某些不兼容ANSI C的特性,例如asm, inline和 typeof关键字,以及诸如unix和vax这些表明当前系统类型的预定义宏.同时开启不受欢迎和极少使用的ANSI trigraph特性,以及禁止`$’成为标识符的一部分.尽管使用了`-ansi’选项,下面这些可选的关键字, __asm__, __extension__, __inline__和__typeof__仍然有效.你当然不会把他们用在ANSI C程序中,但可以把他们放在头文件里,因为编译包含这些头文件的程序时,可能会指定 `-ansi’选项.另外一些预定义宏,如__unix__和__vax__,无论有没有使用 `-ansi’选项,始终有效.使用`-ansi’选项不会自动拒绝编译非ANSI程序,除非增加`-pedantic’选项作为 `-ansi’选项的补充.使用`-ansi’选项的时候,预处理器会预定义一个__STRICT_ANSI__宏.有些头文件关注此宏,以避免声明某些函数,或者避免定义某些宏,这些函数和宏不被ANSI标准调用;这样就不会干扰在其他地方使用这些名字的程序了.-fno-asm不把asm, inline或typeof当作关键字,因此这些词可以用做标识符.用 __asm__, __inline__和__typeof__能够替代他们. `-ansi’ 隐含声明了`-fno-asm’.-fno-builtin不接受不是两个下划线开头的内建函数(built-in function).目前受影响的函数有_exit, abort, abs, alloca, cos, exit, fabs, labs, memcmp, memcpy, sin, sqrt, strcmp, strcpy,和strlen. `-ansi’选项能够阻止alloca和_exit成为内建函数.-fhosted按宿主环境编译;他隐含声明了`-fbuiltin’选项,而且警告不正确的main函数声明.-ffreestanding按独立环境编译;他隐含声明了`-fno-builtin’选项,而且对main函数没有特别要求.(译注:宿主环境(hosted environment)下所有的标准库可用, main函数返回一个int值,典型例子是除了内核以外几乎所有的程序.对应的独立环境(freestanding environment)不存在标准库,程序入口也不一定是 main,最明显的例子就是操作系统内核.详情参考gcc网站最近的资料)-fno-strict-prototype对于没有参数的函数声明,例如`int foo ();’,按C风格处理---即不说明参数个数或类型. (仅针对C++).正常情况下,这样的函数foo在C++中意味着参数为空.-trigraphs支持ANSI C trigraphs. `-ansi’选项隐含声明了`-trigraphs’.-traditional试图支持传统C编译器的某些方面.详见GNU C手册,我们已经把细节清单从这里删除,这样当内容过时后,人们也不会埋怨我们.除了一件事:对于C++程序(不是C), `-traditional’选项带来一个附加效应,允许对 this赋值.他和`-fthis-is-variable’选项的效果一样.-traditional-cpp试图支持传统C预处理器的某些方面.特别是上面提到有关预处理器的内容,但是不包括 `-traditional’选项的其他效应.-fdollars-in-identifiers允许在标识符(identifier)中使用`$’字符(仅针对C++).你可以指定 `-fno-dollars-in-identifiers’选项显明禁止使用`$’符. (GNU C++在某些目标系统缺省允许`$’符,但不是所有系统.)-fenum-int-equiv允许int类型到枚举类型(enumeration)的隐式转换(仅限于C++).正常情况下GNU C++允许从 enum到int的转换,反之则不行.-fexternal-templates为模板声明(template declaration)产生较小的代码(仅限于C++),方法是对于每个模板函数 (template function),只在定义他们的地方生成一个副本.想要成功使用这个选项,你必须在所有使用模板的文件中,标记`#pragma implementation’ (定义)或`#pragma interface’ (声明).当程序用`-fexternal-templates’编译时,模板实例(template instantiation) 全部是外部类型.你必须让需要的实例在实现文件中出现.可以通过typedef实现这一点,他引用所需的每个实例.相对应的,如果编译时使用缺省选项`-fno-external-templates’,所有模板实例明确的设为内置.-fall-virtual所有可能的成员函数默认为虚函数.所有的成员函数(除了构造子函数和new或delete 成员操作符)视为所在类的虚函数.这不表明每次调用成员函数都将通过内部虚函数表.有些情况下,编译器能够判断出可以直接调用某个虚函数;这时就直接调用.-fcond-mismatch允许条件表达式的第二和第三个参数的类型不匹配.这种表达式的值是void.-fthis-is-variable允许对this赋值(仅对C++).合并用户自定义的自由存储管理机制到C++后,使可赋值的 `this’显得不合时宜.因此,默认情况下,类成员函数内部对this赋值是无效操作.然而为了向后兼容,你可以通过`-fthis-is-variable’选项使这种操作有效.-funsigned-char把char定义为无符号类型,如同unsigned char.各种机器都有自己缺省的char类型.既可能是unsigned char也可能是signed char .理想情况下,当依赖于数据的符号性时,一个可移植程序总是应该使用signed char或unsigned char.但是许多程序已经写成只用简单的char,并且期待这是有符号数(或者无符号数,具体情况取决于编写程序的目标机器).这个选项,和它的反义选项,使那样的程序工作在对应的默认值上.char的类型始终应该明确定义为signed char或unsigned char,即使它表现的和其中之一完全一样.-fsigned-char把char定义为有符号类型,如同signed char.这个选项等同于`-fno-unsigned-char’,他是the negative form of `-funsigned-char’的相反选项.同样, `-fno-signed-char’等价于 `-funsigned-char’.-fsigned-bitfields-funsigned-bitfields-fno-signed-bitfields-fno-unsigned-bitfields如果没有明确声明`signed’或`unsigned’修饰符,这些选项用来定义有符号位域 (bitfield)或无符号位域.缺省情况下,位域是有符号的,因为他们继承的基本整数类型,如int,是有符号数.然而,如果指定了`-traditional’选项,位域永远是无符号数.-fwritable-strings把字符串常量存储到可写数据段,而且不做特别对待.这是为了兼容一些老程序,他们假设字符串常量是可写的. `-traditional’选项也有相同效果.篡改字符串常量是一个非常糟糕的想法; ``常量’’就应该是常量.预处理器选项(Preprocessor Option)下列选项针对C预处理器,预处理器用在正式编译以前,对C 源文件进行某种处理.如果指定了`-E’选项, GCC只进行预处理工作.下面的某些选项必须和`-E’选项一起才有意义,因为他们的输出结果不能用于编译.-include file在处理常规输入文件之前,首先处理文件file,其结果是,文件file的内容先得到编译. 命令行上任何`-D’和`-U’选项永远在`-include file’之前处理, 无论他们在命令行上的顺序如何.然而`-include’和`-imacros’选项按书写顺序处理.-imacros file在处理常规输入文件之前,首先处理文件file,但是忽略输出结果.由于丢弃了文件file的输出内容, `-imacros file’选项的唯一效果就是使文件file中的宏定义生效, 可以用于其他输入文件.在处理`-imacrosfile’选项之前,预处理器首先处理`-D’ 和`-U’选项,并不在乎他们在命令行上的顺序.然而`-include’和 `-imacros’选项按书写顺序处理.-idirafter dir把目录dir添加到第二包含路径中.如果某个头文件在主包含路径(用`-I’添加的路径)中没有找到,预处理器就搜索第二包含路径.-iprefix prefix指定prefix作为后续`-iwithprefix’选项的前缀.-iwithprefix dir把目录添加到第二包含路径中.目录名由prefix和dir合并而成,这里 prefix被先前的`-iprefix’选项指定. -nostdinc不要在标准系统目录中寻找头文件.只搜索`-I’选项指定的目录(以及当前目录,如果合适).结合使用`-nostdinc’和`-I-’选项,你可以把包含文件搜索限制在显式指定的目录.-nostdinc++不要在C++专用标准目录中寻找头文件,但是仍然搜索其他标准目录. (当建立`libg++’时使用这个选项.) -undef不要预定义任何非标准宏. (包括系统结构标志).-E仅运行C预处理器.预处理所有指定的C源文件,结果送往标准输出或指定的输出文件.-C告诉预处理器不要丢弃注释.配合`-E’选项使用.-P告诉预处理器不要产生`#line’命令.配合`-E’选项使用.-M [ -MG ]告诉预处理器输出一个适合make的规则,用于描述各目标文件的依赖关系.对于每个源文件,预处理器输出一个make规则,该规则的目标项(target)是源文件对应的目标文件名,依赖项(dependency)是源文件中 `#include引用的所有文件.生成的规则可以是单行,但如果太长,就用`\’-换行符续成多行.规则显示在标准输出,不产生预处理过的C程序.`-M’隐含了`-E’选项.`-MG’要求把缺失的头文件按存在对待,并且假定他们和源程序文件在同一目录下.必须和 `-M’选项一起用.-MM [ -MG ]和`-M’选项类似,但是输出结果仅涉及用户头文件,象这样`#include file"’.忽略系统头文件如`#include <file>’.-MD和`-M’选项类似,但是把依赖信息输出在文件中,文件名通过把输出文件名末尾的`.o’替换为 `.d’产生.同时继续指定的编译工作---`-MD’不象`-M’那样阻止正常的编译任务.Mach的实用工具`md’能够合并`.d’文件,产生适用于`make’命令的单一的依赖文件.-MMD和`-MD’选项类似,但是输出结果仅涉及用户头文件,忽略系统头文件.-H除了其他普通的操作, GCC显示引用过的头文件名.-Aquestion(answer)如果预处理器做条件测试,如`#if #question(answer)’,该选项可以断言(Assert) question的答案是answer. -A-’关闭一般用于描述目标机的标准断言.-Dmacro定义宏macro,宏的内容定义为字符串`1’.-Dmacro=defn定义宏macro的内容为defn.命令行上所有的`-D’选项在 `-U’选项之前处理.-Umacro取消宏macro. `-U’选项在所有的`-D’选项之后处理,但是优先于任何 `-include’或`-imacros’选项.-dM告诉预处理器输出有效的宏定义列表(预处理结束时仍然有效的宏定义).该选项需结合`-E’选项使用.-dD告诉预处理器把所有的宏定义传递到输出端,按照出现的顺序显示.-dN和`-dD’选项类似,但是忽略宏的参量或内容.只在输出端显示`#define name.汇编器选项(ASSEMBLER OPTION)-Wa,option把选项option传递给汇编器.如果option含有逗号,就在逗号处分割成多个选项.连接器选项(LINKER OPTION)下面的选项用于编译器连接目标文件,输出可执行文件的时候.如果编译器不进行连接,他们就毫无意义.object-file-name如果某些文件没有特别明确的后缀a special recognized suffix, GCC就认为他们是目标文件或库文件. (根据文件内容,连接器能够区分目标文件和库文件).如果GCC执行连接操作,这些目标文件将成为连接器的输入文件.-llibrary连接名为library的库文件.连接器在标准搜索目录中寻找这个库文件,库文件的真正名字是`liblibrary.a’.连接器会当做文件名得到准确说明一样引用这个文件.搜索目录除了一些系统标准目录外,还包括用户以`-L’选项指定的路径.一般说来用这个方法找到的文件是库文件---即由目标文件组成的归档文件(archive file).连接器处理归档文件的方法是:扫描归档文件,寻找某些成员,这些成员的符号目前已被引用,不过还没有被定义.但是,如果连接器找到普通的目标文件,而不是库文件,就把这个目标文件按平常方式连接进来.指定`-l’选项和指定文件名的唯一区别是, `-l选项用`lib’和`.a’把library包裹起来,而且搜索一些目录.-lobjc这个-l选项的特殊形式用于连接Objective C程序.-nostartfiles不连接系统标准启动文件,而标准库文件仍然正常使用.-nostdlib不连接系统标准启动文件和标准库文件.只把指定的文件传递给连接器.-static在支持动态连接(dynamic linking)的系统上,阻止连接共享库.该选项在其他系统上无效.-shared生成一个共享目标文件,他可以和其他目标文件连接产生可执行文件.只有部分系统支持该选项.-symbolic建立共享目标文件的时候,把引用绑定到全局符号上.对所有无法解析的引用作出警告(除非用连接编辑选项 `-Xlinker -z -Xlinker defs’取代).只有部分系统支持该选项.-Xlinker option把选项option传递给连接器.可以用他传递系统特定的连接选项, GNU CC无法识别这些选项.如果需要传递携带参数的选项,你必须使用两次`-Xlinker’,一次传递选项,另一次传递他的参数. 例如,如果传递`-assert definitions’,你必须写成`-Xlinker -assert -Xlinker definitions’,而不能写成`-Xlinker "-assert definitions"’,因为这样会把整个字符串当做一个参数传递,显然这不是连接器期待的.-Wl,option把选项option传递给连接器.如果option中含有逗号,就在逗号处分割成多个选项.-u symbol使连接器认为取消了symbol的符号定义,从而连接库模块以取得定义.你可以使用多个 `-u’选项,各自跟上不同的符号,使得连接器调入附加的库模块.目录选项(DIRECTORY OPTION)下列选项指定搜索路径,用于查找头文件,库文件,或编译器的某些成员:-Idir在头文件的搜索路径列表中添加dir 目录.-I-任何在`-I-’前面用`-I’选项指定的搜索路径只适用于`#include "file"’这种情况;他们不能用来搜索`#include <file>’包含的头文件.如果用`-I’选项指定的搜索路径位于`-I-’选项后面,就可以在这些路径中搜索所有的 `#include’指令. (一般说来-I选项就是这么用的.)还有, `-I-’选项能够阻止当前目录(存放当前输入文件的地方)成为搜索`#include "file"’的第一选择.没有办法克服`-I-’选项的这个效应.你可以指定 `-I.’搜索那个目录,它在调用编译器时是当前目录.这和预处理器的默认行为不完全一样,但是结果通常令人满意.`-I-’不影响使用系统标准目录,因此, `-I-’和`-nostdinc’是不同的选项.-Ldir在`-l’选项的搜索路径列表中添加dir目录.-Bprefix这个选项指出在何处寻找可执行文件,库文件,以及编译器自己的数据文件.编译器驱动程序需要执行某些下面的子程序: `cpp’, `cc1’ (或C++的 `cc1plus’), `as’和`ld’.他把prefix当作欲执行的程序的前缀,既可以包括也可以不包括`machine/version/’.对于要运行的子程序,编译器驱动程序首先试着加上`-B’前缀(如果存在).如果没有找到文件,或没有指定 `-B’选项,编译器接着会试验两个标准前缀`/usr/lib/gcc/’和 `/usr/local/lib/gcc-lib/’.如果仍然没能够找到所需文件,编译器就在`PATH’环境变量指定的路径中寻找没加任何前缀的文件名.如果有需要,运行时(run-time)支持文件`libgcc.a’也在`-B’前缀的搜索范围之内. 如果这里没有找到,就在上面提到的两个标准前缀中寻找,仅此而已.如果上述方法没有找到这个文件,就不连接他了.多数情况的多数机器上, `libgcc.a’并非必不可少.你可以通过环境变量GCC_EXEC_PREFIX获得近似的效果;如果定义了这个变量,其值就和上面说的一样用做前缀.如果同时指定了`-B’选项和GCC_EXEC_PREFIX变量,编译器首先使用 `-B’选项,然后才尝试环境变量值.警告选项(WARNING OPTION)警告是针对程序结构的诊断信息,程序不一定有错误,而是存在风险,或者可能存在错误.下列选项控制GNU CC产生的警告的数量和类型:-fsyntax-only检查程序中的语法错误,但是不产生输出信息.-w禁止所有警告信息.-Wno-import禁止所有关于#import的警告信息.-pedantic打开完全服从ANSI C标准所需的全部警告诊断;拒绝接受采用了被禁止的语法扩展的程序.无论有没有这个选项,符合ANSI C标准的程序应该能够被正确编译(虽然极少数程序需要`-ansi’ 选项).然而,如果没有这个选项,某些GNU扩展和传统C特性也得到支持.使用这个选项可以拒绝这些程序.没有理由使用这个选项,他存在只是为了满足一些书呆子(pedant).对于替选关键字(他们以`__’开始和结束) `-pedantic’不会产生警告信息. Pedantic 也不警告跟在__extension__后面的表达式.不过只应该在系统头文件中使用这种转义措施,应用程序最好避免.-pedantic-errors该选项和`-pedantic’类似,但是显示错误而不是警告.-W对下列事件显示额外的警告信息:*非易变自动变量(nonvolatile automatic variable)可能在调用longjmp时发生改变. 这些警告仅在优化编译时发生.编译器只知道对setjmp的调用,他不可能知道会在哪里调用longjmp,事实上一个信号处理例程可以在程序的任何地点调用他.其结果是,即使程序没有问题,你也可能会得到警告,因为无法在可能出现问题的地方调用longjmp.*既可以返回值,也可以不返回值的函数. (缺少结尾的函数体被看作不返回函数值)例如,下面的函数将导致这种警告:foo (a){if (a > 0)return a;}由于GNU CC不知道某些函数永不返回(含有abort和longjmp),因此有可能出现虚假警告.*表达式语句或逗号表达式的左侧没有产生作用(side effect).如果要防止这种警告,应该把未使用的表达式强制转换为void类型.例如,这样的表达式`x[i,j]’会导致警告,而`x[(void)i,j]’就不会.*无符号数用`>’或`<=’和零做比较.-Wimplicit-int警告没有指定类型的声明.-Wimplicit-function-declaration警告在声明之前就使用的函数.-Wimplicit同-Wimplicit-int和-Wimplicit-function-declaration.-Wmain如果把main函数声明或定义成奇怪的类型,编译器就发出警告.典型情况下,这个函数用于外部连接, 返回int数值,不需要参数,或指定两个参数.-Wreturn-type如果函数定义了返回类型,而默认类型是int型,编译器就发出警告.同时警告那些不带返回值的 return语句,如果他们所属的函数并非void类型.-Wunused如果某个局部变量除了声明就没再使用,或者声明了静态函数但是没有定义,或者某条语句的运算结果显然没有使用, 编译器就发出警告.-Wswitch如果某条switch语句的参数属于枚举类型,但是没有对应的case语句使用枚举元素,编译器就发出警告. ( default语句的出现能够防止这个警告.)超出枚举范围的case语句同样会导致这个警告.-Wcomment如果注释起始序列`/*’出现在注释中,编译器就发出警告.。
GCC 中文手册

GCC中文手册NAMEgcc,g++-GNU工程的C和C++编译器(egcs-1.1.2)总览(SYNOPSIS)gcc[option|filename ]...g++[option|filename ]...警告(WARNING)本手册页内容摘自GNU C编译器的完整文档,仅限于解释选项的含义.除非有人自愿维护,否则本手册页不再更新.如果发现手册页和软件之间有所矛盾,请查对Info文件, Info 文件是权威文档.如果我们发觉本手册页的内容由于过时而导致明显的混乱和抱怨时,我们就停止发布它.不可能有其他选择,象更新Info文件同时更新man手册,因为其他维护GNU CC的工作没有留给我们时间做这个. GNU工程认为man手册是过时产物,应该把时间用到别的地方.如果需要完整和最新的文档,请查阅Info文件`gcc'或Using and Porting GNU CC (for version 2.0) (使用和移植GNU CC 2.0) 手册.二者均来自Texinfo原文件 gcc.texinfo.描述(DESCRIPTION)C和C++编译器是集成的.他们都要用四个步骤中的一个或多个处理输入文件: 预处理(preprocessing),编译(compilation),汇编(assembly)和连接(linking).源文件后缀名标识源文件的语言,但是对编译器来说,后缀名控制着缺省设定:gcc认为预处理后的文件(.i)是C文件,并且设定C形式的连接.g++认为预处理后的文件(.i)是C++文件,并且设定C++形式的连接.源文件后缀名指出语言种类以及后期的操作:.c C源程序;预处理,编译,汇编.C C++源程序;预处理,编译,汇编.cc C++源程序;预处理,编译,汇编.cxx C++源程序;预处理,编译,汇编.m Objective-C源程序;预处理,编译,汇编.i预处理后的C文件;编译,汇编.ii预处理后的C++文件;编译,汇编.s汇编语言源程序;汇编.S汇编语言源程序;预处理,汇编.h预处理器文件;通常不出现在命令行上其他后缀名的文件被传递给连接器(linker).通常包括:.o目标文件(Object file).a归档库文件(Archive file)除非使用了-c, -S,或-E选项(或者编译错误阻止了完整的过程),否则连接总是 最后的步骤.在连接阶段中,所有对应于源程序的.o文件, -l库文件,无法识别的文件名(包括指定的 .o目标文件和.a库文件)按命令行中的顺序传递给连接器.选项(OPTIONS)选项必须分立给出: `-dr'完全不同于`-d -r '.大多数`-f'和`-W'选项有两个相反的格式: -f name和 -fno-name (或-W name和-Wno-name).这里 只列举不是默认选项的格式.下面是所有选项的摘要,按类型分组,解释放在后面的章节中.总体选项(Overall Option)-c -S -E -o file -pipe -v -x language语言选项(Language Option)-ansi -fall-virtual -fcond-mismatch -fdollars-in-identifiers -fenum-int-equiv -fexternal-templates -fno-asm -fno-builtin -fhosted -fno-hosted -ffreestanding -fno-freestanding -fno-strict-prototype -fsigned-bitfields -fsigned-char -fthis-is-variable -funsigned-bitfields -funsigned-char -fwritable-strings -traditional -traditional-cpp -trigraphs警告选项(Warning Option)-fsyntax-only -pedantic -pedantic-errors -w -W -Wall -Waggregate-return -Wcast-align -Wcast-qual -Wchar-subscript -Wcomment -Wconversion -Wenum-clash -Werror -Wformat -Wid-clash-len -Wimplicit -Wimplicit-int -Wimplicit-function-declaration -Winline -Wlong-long -Wmain -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wno-import -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wshadow -Wstrict-prototypes -Wswitch -Wtemplate-debugging -Wtraditional -Wtrigraphs -Wuninitialized -Wunused -Wwrite-strings调试选项(Debugging Option)-a -d letters -fpretend-float -g -g level -gcoff -gxcoff -gxcoff+ -gdwarf -gdwarf+ -gstabs -gstabs+ -ggdb -p -pg -save-temps -print-file-name=library -print-libgcc-file-name -print-prog-name=program优化选项(Optimization Option)-fcaller-saves -fcse-follow-jumps -fcse-skip-blocks -fdelayed-branch -felide-constructors -fexpensive-optimizations -ffast-math -ffloat-store -fforce-addr -fforce-mem -finline-functions -fkeep-inline-functions -fmemoize-lookups -fno-default-inline -fno-defer-pop -fno-function-cse -fno-inline -fno-peephole -fomit-frame-pointer -frerun-cse-after-loop -fschedule-insns -fschedule-insns2 -fstrength-reduce -fthread-jumps -funroll-all-loops -funroll-loops -O -O2 -O3预处理器选项(Preprocessor Option)-A assertion -C -dD -dM -dN -D macro[=defn] -E -H -idirafter dir -include file -imacros file -iprefix file -iwithprefix dir -M -MD -MM -MMD -nostdinc -P -U macro -undef汇编器选项(Assembler Option)-Wa,option连接器选项(Linker Option)-l library -nostartfiles -nostdlib -static -shared -symbolic -Xlinker option -Wl,option -u symbol目录选项(Directory Option)-B prefix -I dir -I- -L dir目标机选项(Target Option)-b machine -V version配置相关选项(Configuration Dependent Option)M680x0 选项-m68000 -m68020 -m68020-40 -m68030 -m68040 -m68881 -mbitfield -mc68000 -mc68020 -mfpa -mnobitfield -mrtd -mshort -msoft-floatVAX选项-mg -mgnu -munixSPARC选项-mepilogue -mfpu -mhard-float -mno-fpu -mno-epilogue -msoft-float -msparclite -mv8 -msupersparc -mcypressConvex选项-margcount -mc1 -mc2 -mnoargcountAMD29K选项-m29000 -m29050 -mbw -mdw -mkernel-registers -mlarge -mnbw -mnodw -msmall -mstack-check -muser-registersM88K选项-m88000 -m88100 -m88110 -mbig-pic -mcheck-zero-division -mhandle-large-shift -midentify-revision -mno-check-zero-division -mno-ocs-debug-info -mno-ocs-frame-position -mno-optimize-arg-area -mno-serialize-volatile -mno-underscores -mocs-debug-info -mocs-frame-position -moptimize-arg-area -mserialize-volatile -mshort-data-num -msvr3 -msvr4 -mtrap-large-shift -muse-div-instruction -mversion-03.00 -mwarn-passed-structsRS6000选项-mfp-in-toc -mno-fop-in-tocRT选项-mcall-lib-mul -mfp-arg-in-fpregs -mfp-arg-in-gregs -mfull-fp-blocks -mhc-struct-return -min-line-mul -mminimum-fp-blocks -mnohc-struct-return MIPS选项-mcpu=cpu type -mips2 -mips3 -mint64 -mlong64 -mmips-as -mgas -mrnames -mno-rnames -mgpopt -mno-gpopt -mstats -mno-stats -mmemcpy -mno-memcpy -mno-mips-tfile -mmips-tfile -msoft-float -mhard-float -mabicalls -mno-abicalls -mhalf-pic -mno-half-pic -G num -nocppi386选项-m486 -mno-486 -msoft-float -mno-fp-ret-in-387HPPA选项-mpa-risc-1-0 -mpa-risc-1-1 -mkernel -mshared-libs -mno-shared-libs -mlong-calls -mdisable-fpregs -mdisable-indexing -mtrailing-coloni960选项-m cpu-type -mnumerics -msoft-float -mleaf-procedures -mno-leaf-procedures -mtail-call -mno-tail-call -mcomplex-addr -mno-complex-addr -mcode-align -mno-code-align -mic-compat -mic2.0-compat -mic3.0-compat -masm-compat -mintel-asm -mstrict-align -mno-strict-align -mold-align -mno-old-alignDEC Alpha选项-mfp-regs -mno-fp-regs -mno-soft-float -msoft-floatSystem V选项-G -Qy -Qn -YP,paths -Ym,dir代码生成选项(Code Generation Option)-fcall-saved-reg -fcall-used-reg -ffixed-reg -finhibit-size-directive -fnonnull-objects -fno-common -fno-ident -fno-gnu-linker -fpcc-struct-return -fpic -fPIC -freg-struct-return -fshared-data -fshort-enums -fshort-double -fvolatile -fvolatile-global -fverbose-asm总体选项(Overall Option)-x language明确指出后面输入文件的语言为language (而不是从文件名后缀得到的默认选择).这个选项应用于后面所有的输入文件,直到遇着下一个`-x'选项. language的可选值有`c', `objective-c', `c-header', `c++', `cpp-output', `assembler',和`assembler-with-cpp'. -x none关闭任何对语种的明确说明,因此依据文件名后缀处理后面的文件(就象是从未使用过`-x'选项).如果只操作四个阶段(预处理,编译,汇编,连接)中的一部分,可以使用`-x'选项(或文件名后缀)告诉 gcc从哪里开始,用`-c', `-S',或`-E'选项告诉gcc到 哪里结束.注意,某些选项组合(例如, `-x cpp-output -E')使gcc不作任何事情.-c编译或汇编源文件,但是不作连接.编译器输出对应于源文件的目标文件.缺省情况下, GCC通过用`.o'替换源文件名后缀`.c', `.i', `.s',等等,产生目标文件名.可以使用-o选项选择其他名字.GCC忽略-c选项后面任何无法识别的输入文件(他们不需要编译或汇编).-S编译后即停止,不进行汇编.对于每个输入的非汇编语言文件,输出文件是汇编语言文件.缺省情况下, GCC通过用`.o'替换源文件名后缀`.c', `.i',等等,产生 目标文件名.可以使用-o 选项选择其他名字.GCC忽略任何不需要编译的输入文件.-E预处理后即停止,不进行编译.预处理后的代码送往标准输出.GCC忽略任何不需要预处理的输入文件.-o file指定输出文件为file.该选项不在乎GCC产生什么输出,无论是可执行文件,目标文件,汇编文件还是预处理后的C代码.由于只能指定一个输出文件,因此编译多个输入文件时,使用`-o'选项没有意义,除非输出一个可执行文件.如果没有使用`-o'选项,默认的输出结果是:可执行文件为`a.out', `source.suffix '的目标文件是`source.o',汇编文件是 `source.s',而预处理后的C源代码送往标准输出.-v(在标准错误)显示执行编译阶段的命令.同时显示编译器驱动程序,预处理器,编译器的版本号.-pipe在编译过程的不同阶段间使用管道而非临时文件进行通信.这个选项在某些系统上无法工作,因为那些系统的汇编器不能从管道读取数据. GNU的汇编器没有这个问题.语言选项(LANGUAGE OPTIONS)下列选项控制编译器能够接受的C "方言":-ansi支持符合ANSI标准的C程序.这样就会关闭GNU C中某些不兼容ANSI C的特性,例如asm, inline和 typeof关键字,以及诸如unix和vax这些表明当前系统类型的预定义宏.同时开启 不受欢迎和极少使用的ANSI trigraph 特性,以及禁止`$'成为标识符的一部分.尽管使用了`-ansi'选项,下面这些可选的关键字, __asm__, __extension__, __inline__和__typeof__仍然有效.你当然不会把 他们用在ANSI C程序中,但可以把他们放在头文件里,因为编译包含这些头文件的程序时,可能会指定 `-ansi'选项.另外一些预定义宏,如__unix__和__vax__,无论有没有使用 `-ansi'选项,始终有效.使用`-ansi'选项不会自动拒绝编译非ANSI程序,除非增加`-pedantic'选项作为 `-ansi'选项的补充.使用`-ansi'选项的时候,预处理器会预定义一个__STRICT_ANSI__宏.有些头文件 关注此宏,以避免声明某些函数,或者避免定义某些宏,这些函数和宏不被ANSI标准调用;这样就不会干扰在其他地方 使用这些名字的程序了.-fno-asm不把asm, inline或typeof当作关键字,因此这些词可以用做标识符.用__asm__,__inline__和__typeof__能够替代他们. `-ansi' 隐含声明了`-fno-asm'.-fno-builtin不接受不是两个下划线开头的内建函数(built-in function).目前受影响的函数有_exit,abort, abs, alloca, cos, exit, fabs, labs, memcmp, memcpy, sin, sqrt,strcmp, strcpy,和strlen.`-ansi'选项能够阻止alloca和_exit成为内建函数.-fhosted按宿主环境编译;他隐含声明了`-fbuiltin'选项,而且警告不正确的main函数声明.-ffreestanding按独立环境编译;他隐含声明了`-fno-builtin'选项,而且对main函数没有特别要求.(译注:宿主环境(hosted environment)下所有的标准库可用, main函数返回一个int值,典型例子是除了 内核以外几乎所有的程序.对应的独立环境(freestanding environment)不存在标准库,程序入口也不一定是 main,最明显的例子就是操作系统内核.详情参考gcc网站最近的资料)-fno-strict-prototype对于没有参数的函数声明,例如`int foo ();',按C风格处理---即不说明参数个数或类型. (仅针对C++).正常情况下,这样的函数foo在C++中意味着参数为空.-trigraphs支持ANSI C trigraphs. `-ansi'选项隐含声明了`-trigraphs'.-traditional试图支持传统C编译器的某些方面.详见GNU C手册,我们已经把细节清单从这里删除,这样当内容过时后,人们也不会埋怨我们.除了一件事:对于C++程序(不是C), `-traditional'选项带来一个附加效应,允许对 this赋值.他和`-fthis-is-variable'选项的效果一样.-traditional-cpp试图支持传统C预处理器的某些方面.特别是上面提到有关预处理器的内容,但是不包括`-traditional'选项的其他效应.-fdollars-in-identifiers允许在标识符(identifier)中使用`$'字符(仅针对C++).你可以指定`-fno-dollars-in-identifiers'选项显明禁止使用`$'符. (GNU C++在某些目标系统缺省允许`$'符,但不是所有系统.)-fenum-int-equiv允许int类型到枚举类型(enumeration)的隐式转换(仅限于C++).正常情况下GNU C++允许从enum到int的转换,反之则不行.-fexternal-templates为模板声明(template declaration)产生较小的代码(仅限于C++),方法是对于每个模板函数(template function),只在定义他们的地方生成一个副本.想要成功使用这个选项,你必须在所有使用模板的文件中,标记`#pragma implementation' (定义)或`#pragmainterface' (声明).当程序用`-fexternal-templates'编译时,模板实例(template instantiation) 全部是外部类型.你必须让需要的实例在实现文件中出现.可以通过typedef实现这一点,他引用所需的每个 实例.相对应的,如果编译时使用缺省选项`-fno-external-templates',所有模板实例明确的设为内置.-fall-virtual所有可能的成员函数默认为虚函数.所有的成员函数(除了构造子函数和new或delete成员操作符)视为所在类的虚函数.这不表明每次调用成员函数都将通过内部虚函数表.有些情况下,编译器能够判断出可以直接调用某个虚函数;这时就 直接调用.-fcond-mismatch允许条件表达式的第二和第三个参数的类型不匹配.这种表达式的值是void.-fthis-is-variable允许对this赋值(仅对C++).合并用户自定义的自由存储管理机制到C++后,使可赋值的`this'显得不合时宜.因此,默认情况下,类成员函数内部对this赋值是无效操作.然而为了向后兼容,你可以通过`-fthis-is-variable'选项使这种操作有效.-funsigned-char把char定义为无符号类型,如同unsigned char.各种机器都有自己缺省的char类型.既可能是unsigned char也可能是signed char .理想情况下,当依赖于数据的符号性时,一个可移植程序总是应该使用signed char或unsigned char.但是许多程序已经写成只用简单的char,并且期待这是有符号数(或者无符号数,具体情况取决于 编写程序的目标机器).这个选项,和它的反义选项,使那样的程序工作在对应的默认值上.char的类型始终应该明确定义为signed char或unsigned char,即使 它表现的和其中之一完全一样.-fsigned-char把char定义为有符号类型,如同signed char.这个选项等同于`-fno-unsigned-char',他是the negative form of `-funsigned-char'的相反选项.同样, `-fno-signed-char'等价于 `-funsigned-char'.-fsigned-bitfields-funsigned-bitfields-fno-signed-bitfields-fno-unsigned-bitfields如果没有明确声明`signed'或`unsigned'修饰符,这些选项用来定义有符号位域(bitfield)或无符号位域.缺省情况下,位域是有符号的,因为他们继承的基本整数类型,如int,是有符号数.然而,如果指定了`-traditional'选项,位域永远是无符号数.-fwritable-strings把字符串常量存储到可写数据段,而且不做特别对待.这是为了兼容一些老程序,他们假设字符串常量是可写的. `-traditional'选项也有相同效果.篡改字符串常量是一个非常糟糕的想法; ``常量''就应该是常量.预处理器选项(Preprocessor Option)下列选项针对C预处理器,预处理器用在正式编译以前,对C 源文件进行某种处理.如果指定了`-E'选项, GCC只进行预处理工作.下面的某些选项必须和`-E'选项一起才 有意义,因为他们的输出结果不能用于编译.-include file在处理常规输入文件之前,首先处理文件file,其结果是,文件file的内容先得到编译. 命令行上任何`-D'和`-U'选项永远在`-include file'之前处理, 无论他们在命令行上的顺序如何.然而`-include'和`-imacros'选项按书写顺序处理.-imacros file在处理常规输入文件之前,首先处理文件file,但是忽略输出结果.由于丢弃了文件file的输出内容, `-imacros file'选项的唯一效果就是使文件file中的宏定义生效, 可以用于其他输入文件.在处理`-imacros file'选项之前,预处理器首先处理`-D' 和`-U'选项,并不在乎他们在命令行上的顺序.然而`-include'和`-imacros'选项按书写顺序处理.-idirafter dir把目录dir添加到第二包含路径中.如果某个头文件在主包含路径(用`-I'添加的路径)中没有找到,预处理器就搜索第二包含路径.-iprefix prefix指定prefix作为后续`-iwithprefix'选项的前缀.-iwithprefix dir把目录添加到第二包含路径中.目录名由prefix和dir合并而成,这里prefix被先前的`-iprefix'选项指定.-nostdinc不要在标准系统目录中寻找头文件.只搜索`-I'选项指定的目录(以及当前目录,如果合适).结合使用`-nostdinc'和`-I-'选项,你可以把包含文件搜索限制在显式指定的目录.-nostdinc++不要在C++专用标准目录中寻找头文件,但是仍然搜索其他标准目录. (当建立`libg++'时使用这个选项.)-undef不要预定义任何非标准宏. (包括系统结构标志).-E仅运行C预处理器.预处理所有指定的C源文件,结果送往标准输出或指定的输出文件.-C告诉预处理器不要丢弃注释.配合`-E'选项使用.-P告诉预处理器不要产生`#line'命令.配合`-E'选项使用.-M [ -MG ]告诉预处理器输出一个适合make的规则,用于描述各目标文件的依赖关系.对于每个源文件,预处理器输出一个make规则,该规则的目标项(target)是源文件对应的目标文件名,依赖项(dependency)是源文件中`#include引用的所有文件.生成的规则可以是单行,但如果太长,就用`\'-换行符续成多行.规则显示在标准输出,不产生预处理过的C程序.`-M'隐含了`-E'选项.`-MG'要求把缺失的头文件按存在对待,并且假定他们和源程序文件在同一目录下.必须和 `-M'选项一起用.-MM [ -MG ]和`-M'选项类似,但是输出结果仅涉及用户头文件,象这样`#include file"'.忽略系统头文件如`#include <file>'.-MD和`-M'选项类似,但是把依赖信息输出在文件中,文件名通过把输出文件名末尾的`.o'替换为`.d'产生.同时继续指定的编译工作---`-MD'不象`-M'那样阻止正常的编译任务.Mach的实用工具`md'能够合并`.d'文件,产生适用于`make'命令的单一的 依赖文件.-MMD和`-MD'选项类似,但是输出结果仅涉及用户头文件,忽略系统头文件.-H除了其他普通的操作, GCC显示引用过的头文件名.-A question(answer)如果预处理器做条件测试,如`#if #question(answer)',该选项可以断言(Assert)question的答案是answer.-A-'关闭一般用于描述目标机的标准断言.-D macro定义宏macro,宏的内容定义为字符串`1'.-D macro=defn定义宏macro的内容为defn.命令行上所有的`-D'选项在`-U'选项之前处理.-U macro取消宏macro. `-U'选项在所有的`-D'选项之后处理,但是优先于任何`-include'或`-imacros'选项.-dM告诉预处理器输出有效的宏定义列表(预处理结束时仍然有效的宏定义).该选项需结合`-E'选项使用.-dD告诉预处理器把所有的宏定义传递到输出端,按照出现的顺序显示.-dN和`-dD'选项类似,但是忽略宏的参量或内容.只在输出端显示`#define name.汇编器选项(ASSEMBLER OPTION)-Wa,option把选项option传递给汇编器.如果option含有逗号,就在逗号处分割成多个选项.连接器选项(LINKER OPTION)下面的选项用于编译器连接目标文件,输出可执行文件的时候.如果编译器不进行连接,他们就毫无意义. object-file-name如果某些文件没有特别明确的后缀a special recognized suffix, GCC就认为他们是目标文件或库文件. (根据文件内容,连接器能够区分目标文件和库文件).如果GCC执行连接操作,这些目标文件将成为连接器的输入文件.-l library连接名为library的库文件.连接器在标准搜索目录中寻找这个库文件,库文件的真正名字是`lib library.a'.连接器会 当做文件名得到准确说明一样引用这个文件.搜索目录除了一些系统标准目录外,还包括用户以`-L'选项指定的路径.一般说来用这个方法找到的文件是库文件---即由目标文件组成的归档文件(archive file).连接器处理归档文件的 方法是:扫描归档文件,寻找某些成员,这些成员的符号目前已被引用,不过还没有被定义.但是,如果连接器找到普通的 目标文件,而不是库文件,就把这个目标文件按平常方式连接进来.指定`-l'选项和指定文件名的唯一区别是, `-l选项用`lib'和`.a'把library包裹起来,而且搜索一些目录.-lobjc这个-l选项的特殊形式用于连接Objective C程序.-nostartfiles不连接系统标准启动文件,而标准库文件仍然正常使用.-nostdlib不连接系统标准启动文件和标准库文件.只把指定的文件传递给连接器.-static在支持动态连接(dynamic linking)的系统上,阻止连接共享库.该选项在其他系统上无效.-shared生成一个共享目标文件,他可以和其他目标文件连接产生可执行文件.只有部分系统支持该选项.-symbolic建立共享目标文件的时候,把引用绑定到全局符号上.对所有无法解析的引用作出警告(除非用连接编辑选项`-Xlinker -z -Xlinker defs'取代).只有部分系统支持该选项.-Xlinker option把选项option传递给连接器.可以用他传递系统特定的连接选项, GNU CC无法识别这些选项.如果需要传递携带参数的选项,你必须使用两次`-Xlinker',一次传递选项,另一次传递他的参数. 例如,如果传递`-assert definitions',你必须写成`-Xlinker -assert -Xlinker definitions',而不能写成`-Xlinker "-assert definitions"',因为这样会把整个 字符串当做一个参数传递,显然这不是连接器期待的.-Wl,option把选项option传递给连接器.如果option中含有逗号,就在逗号处分割成多个选项.-u symbol使连接器认为取消了symbol的符号定义,从而连接库模块以取得定义.你可以使用多个`-u'选项,各自跟上不同的符号,使得连接器调入附加的库模块.目录选项(DIRECTORY OPTION)下列选项指定搜索路径,用于查找头文件,库文件,或编译器的某些成员:-I dir在头文件的搜索路径列表中添加dir 目录.-I-任何在`-I-'前面用`-I'选项指定的搜索路径只适用于`#include "file"'这种情况;他们不能用来搜索`#include <file>'包含的头文件.如果用`-I'选项指定的搜索路径位于`-I-'选项后面,就可以在这些路径中搜索所有的`#include'指令. (一般说来-I选项就是这么用的.)还有, `-I-'选项能够阻止当前目录(存放当前输入文件的地方)成为搜索`#include "file"'的第一选择.没有办法克服`-I-'选项的这个效应.你可以指定 `-I.'搜索那个目录,它在调用编译器时是当前目录.这和预处理器的默认行为不完全一样,但是结果通常 令人满意.`-I-'不影响使用系统标准目录,因此, `-I-'和`-nostdinc'是不同的选项.-L dir在`-l'选项的搜索路径列表中添加dir目录.-B prefix这个选项指出在何处寻找可执行文件,库文件,以及编译器自己的数据文件.编译器驱动程序需要执行某些下面的子程序: `cpp', `cc1' (或C++的 `cc1plus'), `as'和`ld'.他把prefix当作欲执行的程序的 前缀,既可以包括也可以不包括`machine/version/'.对于要运行的子程序,编译器驱动程序首先试着加上`-B'前缀(如果存在).如果没有找到文件,或没有指定 `-B'选项,编译器接着会试验两个标准前缀`/usr/lib/gcc/'和 `/usr/local/lib/gcc-lib/'.如果仍然没能够找到所需文件,编译器就在`PATH'环境变量 指定的路径中寻找没加任何前缀的文件名.如果有需要,运行时(run-time)支持文件`libgcc.a'也在`-B'前缀的搜索范围之内. 如果这里没有找到,就在上面提到的两个标准前缀中寻找,仅此而已.如果上述方法没有找到这个文件,就不连接他了.多数 情况的多数机器上, `libgcc.a'并非必不可少.你可以通过环境变量GCC_EXEC_PREFIX获得近似的效果;如果定义了这个变量,其值就和上面说的 一样用做前缀.如果同时指定了`-B'选项和GCC_EXEC_PREFIX变量,编译器首先使用 `-B'选项,然后才尝试环境变量值.警告选项(WARNING OPTION)警告是针对程序结构的诊断信息,程序不一定有错误,而是存在风险,或者可能存在错误.下列选项控制GNU CC产生的警告的数量和类型:-fsyntax-only检查程序中的语法错误,但是不产生输出信息.-w禁止所有警告信息.-Wno-import禁止所有关于#import的警告信息.-pedantic打开完全服从ANSI C标准所需的全部警告诊断;拒绝接受采用了被禁止的语法扩展的程序.无论有没有这个选项,符合ANSI C标准的程序应该能够被正确编译(虽然极少数程序需要`-ansi' 选项).然而,如果没有这个选项,某些GNU扩展和传统C特性也得到支持.使用这个选项可以拒绝这些程序.没有理由 使用这个选项,他存在只是为了满足一些书呆子(pedant).对于替选关键字(他们以`__'开始和结束) `-pedantic'不会产生警告信息. Pedantic 也不警告跟在__extension__后面的表达式.不过只应该在系统头文件中使用这种转义措施,应用程序最好 避免.-pedantic-errors该选项和`-pedantic'类似,但是显示错误而不是警告.-W对下列事件显示额外的警告信息:*非易变自动变量(nonvolatile automatic variable)可能在调用longjmp时发生改变. 这些警告仅在优化编译时发生.编译器只知道对setjmp的调用,他不可能知道会在哪里调用longjmp,事实上一个 信号处理例程可以在程序的任何地点调用他.其结果是,即使程序没有问题,你也可能会得到警告,因为无法在可能出现问题 的地方调用longjmp.*既可以返回值,也可以不返回值的函数. (缺少结尾的函数体被看作不返回函数值)例如,下面的函数将导致这种警告:foo (a){if (a > 0)return a;}由于GNU CC不知道某些函数永不返回(含有abort和longjmp),因此有可能出现虚假警告.*表达式语句或逗号表达式的左侧没有产生作用(side effect).如果要防止这种警告,应该把未使用的表达式强制转换为void类型.例如,这样的表达式`x[i,j]'会导致警告,而`x[(void)i,j]'就不会.*无符号数用`>'或`<='和零做比较.-Wimplicit-int警告没有指定类型的声明.-Wimplicit-function-declaration警告在声明之前就使用的函数.-Wimplicit同-Wimplicit-int和-Wimplicit-function-declaration.-Wmain如果把main函数声明或定义成奇怪的类型,编译器就发出警告.典型情况下,这个函数用于外部连接, 返回int数值,不需要参数,或指定两个参数.-Wreturn-type如果函数定义了返回类型,而默认类型是int型,编译器就发出警告.同时警告那些不带返回值的return语句,如果他们所属的函数并非void类型.-Wunused如果某个局部变量除了声明就没再使用,或者声明了静态函数但是没有定义,或者某条语句的运算结果显然没有使用, 编译器就发出警告.-Wswitch如果某条switch语句的参数属于枚举类型,但是没有对应的case语句使用枚举元素,编译器就发出警告. ( default语句的出现能够防止这个警告.)超出枚举范围的case语句同样会导致这个警告.-Wcomment如果注释起始序列`/*'出现在注释中,编译器就发出警告.-Wtrigraphs警告任何出现的trigraph (假设允许使用他们).-Wformat检查对printf和scanf等函数的调用,确认各个参数类型和格式串中的一致.-Wchar-subscripts警告类型是char的数组下标.这是常见错误,程序员经常忘记在某些机器上char有符号.-Wuninitialized在初始化之前就使用自动变量.这些警告只可能做优化编译时出现,因为他们需要数据流信息,只有做优化的时候才估算数据流信息.如果不指定 `-O'选项,就不会出现这些警告.这些警告仅针对等候分配寄存器的变量.因此不会发生在声明为volatile的变量上面,不会发生在已经 取得地址的变量,或长度不等于1, 2, 4, 8字节的变量.同样也不会发生在结构,联合或数组上面,即使他们在 寄存器中.注意,如果某个变量只计算了一个从未使用过的值,这里可能不会警告.因为在显示警告之前,这样的计算已经被 数据流分析删除了.这些警告作为可选项是因为GNU CC还没有智能到判别所有的情况,知道有些看上去错误的代码其实是正确的.下面是 一个这样的例子:{int x;switch (y){case 1: x = 1;break;case 2: x = 4;break;case 3: x = 5;}foo (x);。
gcc的使用

GCC使用手册作者:Clock1.前言GCC编译器的手册(GCC MANUAL)的英文版已经非常全面,并且结构也非常完善了,只是一直都没有中文的版本,我这次阅读了GCC编译器的主要内容,对手册的内容进行了结构性的了解,认为有必要对这次阅读的内容进行整理,为以后的工作做准备。
由于我对这个英文手册的阅读也仅仅是结构性的。
因此有很多地方并没有看,所以这篇文档的内容我也只能写出部分,对于以后需要详细了解的地方,会再往这篇文档中增添内容,需要增添的内容主要是编译器的各种开关。
2. GCC功能介绍GCC编译器完成从C、C++、objective-C等源文件向运行在特定CPU硬件上的目标代码的转换(这是任何一个编译器需要完成的任务)。
GCC能够处理的源文件分为C、C++、Objective-C、汇编语言等。
对于这些源文件,用他们的后缀名进行标示。
GCC能够处理的后缀有:a. *.c *.C (C语言)b. *.cxx *.cc (C++语言)c. *.m (面向对象的C)d. *.i (预处理后的C语言源文件)e. *.ii (预处理后的C++语言源文件)f. *.s *.S (汇编语言)h. *.h (头文件)目标文件可以是:a. *.o 编译连接后的目标文件b. *.a 库文件编译器把编译生成目标代码的任务分为以下4步:a.预处理,把预处理命令扫描处理完毕;b.编译,把预处理后的结果编译成汇编或者目标模块;c.汇编,把编译出来的结果汇编成具体CPU上的目标代码模块;d.连接,把多个目标代码模块连接生成一个大的目标模块;3. GCC开关GCC的运行开关共分为11类,这是类开关从11个方面控制着GCC程序的运行,以达到特定的编译目的。
3.1. 全局开关(OVERALL OPTIONS)全局开关用来控制在“GCC功能介绍”中的GCC的4个步骤的运行,在缺省的情况下,这4个步骤都是要执行的,但是当给定一些全局开关后,这些步骤就会在某一步停止执行,这产生中间结果,例如可能你只是需要中间生成的预处理的结果或者是汇编文件(比如拟的目的是为了看某个CPU上的汇编语言怎么写)。
imacros教程iMacros for Chrome

iMacros for ChromeThank your for using iMacros for Chrome, the open-source web automation solution.Note that this version is a Beta version, so please do not expect it to be as polished as its bigger siblings for IE and Firefox.Having said that, iMacros for Chrome is ready to be used for web automation. Its a macrorecorder for your Google Chrome browser. With iMacros for Chrome we are also testing an interesting new GUI layout and the concept of storing iMacros as bookmarklets. We look forward to your feedback!Contents[hide]∙ 1 Installationo 1.1 Add File Accesso 1.2 How to install an extension from outside the Chrome gallery∙ 2 First Steps∙ 3 iMacros as Bookmarklets∙ 4 Social Scripting∙ 5 Demo and Test Macros∙ 6 Command Line Support∙7 Scripting Chromeo7.1 Using Chrome with the iMacros RunAs Agent (iimRunner)7.1.1 Where is the iimDisplay message?∙8 Getting Help∙9 Limitations∙10 Version Historyo10.1 Version Archiveo10.2 How to install an older version∙11 Security∙12 Known Issues∙13 See AlsoInstallation∙ Download the latest version iMacros_for_Chrome - this version fixes the Chrome V35 issues!No administrative rights are required for the installation. All versions of Chrome (Win, Mac and Linux) are supported.This installer supports storing macros inside bookmarks. If this is all you want, then there is nothing else to do. But if you prefer to store macros in regular text files (like iMacros for Firefox/IE do), then please install our new file access modules below.Add File AccessiMacros for Chrome used a NPAPI plugin internally to access the file system. And because Chrome extensions can no longer use the NPAPI (since May 2014) we have to provide the alternative solution - using the new NativeMessaging API of Chrome.This means the default install of iMacros for Chrome V8 and higher allows you to only store macros in bookmarks. If you want to store the macros in text files on your hard drive or you are using macros that access data files (via !DATASOURCE), please install one of these free file access enhancements:Please install iMacros for Chrome before installing the file access module. The installers below contain ONLY the file access code, not the complete iMacros for Chrome extension.∙Windows: => Download File Access Installer∙Mac: => Download File Access Installer (updated Oct 1, 2014)∙Linux:Download tar ball∙∙It can be used for both, Mac and Linux.∙The install script is inside the "gz" file. The command to unpack it from command line is ∙tar -xvf imacros_fio.tar.gz∙After that command is executed the imacros_fio directory is created. Please move that directory to some place where it will be persistent, e.g. ~/iMacros∙then cd to that directory and execute ./install.sh∙(Checksum: MD5 (imacros_fio.tar.gz) = dc668d1b8265443e0ef7314a6bc92b3f)This is how iMacros for Chrome looks without the new and free file access module installed. Once it is installed, you will see the familiar treeview there.How to install an extension from outside the Chrome gallery Extensions that you download from the Chrome Web Store are installed automatically, which is great for distribution, but not so great for development. Recognizing this, Chrome gives you a quick way of loading up your working directory for testing. Let's do that now.∙Visit chrome://extensions in your browser (or open up the Chrome menu by clicking the icon to the far right of the Omnibox: The menu's icon is three horizontal bars.. and select Extensions under the Tools menu to get to the same place).∙Ensure that the Developer mode checkbox in the top right-hand corner is checked.Drag & drop the imacros-yyy.crx beta version on the extension page. This works only on the extension page. Chrome checks if the extension is valid, it'll be loaded up and active right away!This does not work Chrome V36 Beta on Windows: That is caused by a new, upcoming security improvement: Starting with V36, Chrome will block all installs from outside the Google Chrome Gallery! So far this block seems to be only in the Windows version, not Chrome 36 for Linux or Mac. To work around this, install our beta version from the gallery.First StepsAfter you installed iMacros for Chrome you will see the iMacros icon in the toolbar. First we recommend that you look at a few demo macros. After this start recording your first own macro. To get start, a simple website like this wiki or our company website are a good start. To record, open the iMacros panel and click record. When you are done recording, click the stop icon either in the panel or in the Chrome toolbar. The iMacros icon changes to a stop button with line counter during recording and replay.The iMacros for Chrome Panel: You can start playing macros either from the iMacros panel or from your bookmarks or macros that are embedded into websites.The iMacros icon changes to a stop button with line counter during recording and replay.The WAIT command displays the wait time as countdown.The iMacros panel has a loop button to run macros repeatedly. This can be useful for checking a certain web page status or for web testing. While the loop is running, the current loop number is stored in the !LOOP internal variable.Example usage: Create a macro that refreshes the current page every 5 seconds:iMacros as BookmarkletsIf you are used to other iMacros versions, you might be surprised that iMacros for Chrome does not store its macros as text files. The reason for this is that Chrome extensions can not write or read files unless they use a special NPAPI dll (Update: iMacros for Chrome V2.0 Beta has such a DLL and can now read and write normal macros!). Instead we are testing a new concept and store macros as bookmarklets inside the regular Chrome bookmarking system.This means you can take full advantage of the Google Bookmark Sync features or bookmark sync extensions such as Xmarks.As the macros are packed as bookmarklets, you can just drag & drop them to your bookmarks folder or bookmarks bar.Example: Search the German railway website for train connection from Frankfurt International Airport to Mannheim - Select "Proceed to this site" to run the macro!You can rename, edit or delete your iMacros via the the Chrome bookmark managerYou can sync your iMacros macros just like normal bookmarks. And with the iMacros secure password encryption that means that you can even store login macros securely in the cloud.iMacros for Chrome V2 Beta can view, run and edit the standard *.iim text file based macros, just like iMacros for Firefox/IE.Social ScriptingiMacros for Chrome pioneers the social scripting concept. Users can embed the complete macro in a simple link that can be shared with friends and coworkers. Users can also embed the link on their homepage, blog and company Intranet. In this way, users can help website visitors perform certain tasks. Instead of telling visitors how to fill out a form, users can let iMacros fill out the form for them. All information is stored inside the link as a text string, and nothing is stored on our servers.Tip: To send macros (bookmarklets) by email, use the link shortener service. Example usage:"Hi Sandra, which of the available flights do you prefer? Just click the link to run the search and get up-to-date pricing."Demo and Test MacrosFor a list of demo and test macros please see /imacros/chrome/. If these macros replay fine in your Google Chrome browser, then the basic installation of iMacros for Chrome is ok.Command Line SupportThe Google Chrome API does not provide command line information for extensions yet, but user "cammarin" suggested a great way to use iMacros for Chrome via the command line: Embed the iMacros bookmarklet in a local web page.1. Create a bookmark for the macro you want to launch2. Right-click on the bookmark in Chrome and select Edit3. Copy everything in the URL field starting with var e_m64 up to and includingwindow.dispatchEvent(evt);4. Paste this code in place of the line starting with var e_m64 in the HTML file shown below Example:Example command line / batch file:"test.htm" is the local website with the bookmarklet. Note that you need to open another tab first, otherwise Chrome is not ready to start the bookmarklet. So the workaround is to simply open "" before our local website with the bookmarklet. This way you can also start your macro via the Windows task scheduler or a Linux crown job.Update: This approach is no longer working. We discovered that you can make it work by adding a call to alert() as the first line in the launchMacro() function. Obviously this is not acceptable since it would require user intervention to dismiss the dialog. If you know of a fix or other approach, please post the solution here.Scripting ChromeGoogle Chrome, the complete browser, can be scripted with the commercial iMacros Enterprise Edition (= iMacros Scripting API). The API allows you to control Chrome from external software (C++, C#, Python, Perl,...). For details, see the chapter with the iimOpen command.Using Chrome with the iMacros RunAs Agent (iimRunner)1. iimRunner only works with a non-default Chrome UserDataDir (aka profile)2. Make sure the iMacros add-on is installed in the new user profile.3. In order to launch Chrome with a different user profile via the iMacros scripting interface(e.g. iimOpen("-cr -crUserData C:\MyProfile")) or with iimRunner (e.g. iimOpen("-cr-runner -crUserData C:\MyProfile")), you need to allow access to file URLs:1. Go to Tools - Extensions and click the small triangle next to the iMacros add-on2. Make sure "Allow access to file URLs" is checkedWhere is the iimDisplay message?Due to Chrome's UI, we opted to show messages output by iimDisplay as a desktopnotification pop-up window.In iMacros for Chrome, if the sidebar is not available (e.g. if you start the browser from scripting interface API or run macros from bookmarks menu) errors and iimDisplay() messages are shown in a desktop notification pop-up window.Getting HelpIf you run into any issues, please don't hesitate to contact us on our support forum. Take a quick look through the forum before asking your question, we might already have a solution or work around available.LimitationsWhile iMacros for Chrome works well for many web automation tasks, some iMacros features are not yet implemented. But we are working on it.Not yet available:∙Some of the built-in variables∙Dialog Manager* (ONDIALOG)∙DirectScreen Technology & Image Recognition∙What feature do you need most urgently? - Please let us know in the iMacros for Chrome user forum so we can prioritize our work.(*) Feature requires updates to the Chrome extensions API before we can implement it. Version HistoryRead what's new:∙2014-05-28 V8.04Download now∙New: Chrome V35 bug workaround∙New: New Scripting interface, workaround for Chrome's block of NPAPI dlls - requires separate installer.Due to Chrome restrictions, the updated extension only supports macros inside bookmarks. For file access, please install our new file access modules - get themat iMacros_for_Chrome#Installation.∙2014-03-10 V7.03 Download now∙Fixed: Shrinking sidebar bug (only Linux systems affected). This fix is actually a workaround for a Chrome bug.∙2014-03-10 V7.02 Download now∙New: Significantly improved UI∙New: Upload support for AlertFox Website Monitoring∙Fixed: Many smaller bug fixes and tweaks∙2013-07-05 V6.06 Download now∙New: New indicator for the recording/replay position∙Improved: Bookmarklet conversion∙Fixed: Many smaller bug fixes and tweaksImportant note for iMacros Enterprise Edition users: The updated iMacros Chrome Scripting Interface requires iMacros V9.02 or this patch. After downloading the patch, unzip and run "install.cmd" as administrator. It updates the Chrome connector to the latest version. This patch supports both, iMacros 8 and 9.V6.06 features the new floating iMacros icon...(also in the new iMacros for Firefox)∙2012-10-08 V5.21∙Added: ONERRORDIALOG∙Added: EVAL∙Added: Performance log feature∙Added: SET !FILE_PROFILER∙Improved: iimTakeBrowserScreenshot support∙Improved: Bookmarklets support - now iMacros for Chrome and iMacros for Firefox bookmarklets have the same format.∙Fixed: MAC Chrome compatibility issues introduced by Chrome V22∙Fixed: BACK button not recorded∙Fixed: Many smaller bug fixes∙2012-06-14 V5.11 Click here to download from the Chrome Gallery or Click here to download∙Fixed: Previous V5.10 broke some scripts (sorry about that!)∙Fixed: RuntimeError: net::ERR_ABORTED issue∙Fixed: Several smaller bug fixes∙2012-04-24 V5.01∙Added: FRAME support∙Added: SAVEAS support∙Added: EVAL support∙Added: Support for TIMEOUT_PAGE and TIMEOUT_MACRO∙Improved: iMacros Chrome icon is changed only on those windows where replaying or recording happens∙Fixed: Negative counter issue∙Fixed: Several smaller bug fixes∙2012-02-09 V4.01∙Added: Visual display for recorded commands∙Added: Visual display for replayed commands∙Added: iimDisplay support∙Improved: Web Scripting Interface: control Chrome with iimInit ("-cr").New visual display for recording and replayiMacros for Chrome can store macros as text files (fully compatible with iMacros for IE and Firefox) and also embeded them inside bookmarks - perfect for quick access and syncing macros with your bookmarks. Use the macro storage option to switch.∙2011-07-15 V3.5.3∙Added: Re-added support for iMacros in bookmarks∙Added: Conversion of macros between "stored as local file" and "stored as bookmarks". Bookmark storage is great for automated syncing.∙Added: Double treeview - view macros stored as files and in bookmarks.∙2011-05-05 V3.5.1 Beta∙Added: Mac OSX support!∙Added: Improved iimInit ("-cr") support∙2011-01-20 V3.0.2 Beta∙Added: iimInit ("-cr") support. You can now remote control Chrome just like IE or Firefox. iMacros Enterprise Edition V7.22 or later is required in addition to theChrome extension.∙Added: Side bar∙Fixed: Several smaller issues∙2010-05-20 V2.0.1 Beta∙Added: Read/write/edit standard text based iMacros macro files ("*.iim" files).∙Added: Drag & Drop tree view∙Added: Run more than one instance (requires Google Chrome V5.x)∙Fixed: Several minor issues∙2010-02-08 V1.1.1∙Added: !CLIPBOARD command: SET !CLIPBOARD "Hi" works, but {{!CLIPBOARD}} does not currently work due to a bug in Chrome.∙Added: Macro edit, rename and delete with right-click∙Added: STOPWATCH - Result is written to Chrome Javascript Console∙Fixed: Several minor issues∙2009-12-8 V1.0.3∙iMacros for Chrome is a featured extension at the launch of the new Google Extension Gallery∙Added: PROMPT∙Added: PAUSE∙2009-12-7 V1.0.2∙Added: !URLCURRENT∙Added: !VAR1, !VAR3, !VAR3∙Added: SET !ERRORIGNORE YES/NO∙2009-12-5 V1.0.0∙Added: Improved GUI, panel now stays open during record and replay∙Added: Pause button∙Added: LOOP button & {{!LOOP}} variable∙Added: REFRESH∙Fixed: Several smaller issues∙2009-12-1 V0.6.5∙Added: Line numbers and WAIT time in seconds are displayed as text in the browser action icon∙Fixed: Another page load timing issue∙2009-11-30 V0.6.1∙Fixed: Page load timing issue∙2009-11-27 V0.6.0∙Added: SET !ENCRYPTION support - full 256-bit AES support∙Added: Enhanced option dialog∙Added: Demo macros available at /imacros/chrome∙2009-11-23 V0.5.0∙Added: Browser Action support∙Fixed: Encoding issue for Non-ASCII characters in macro. Bookmarklets now Base64 encoded.∙Fixed: Several smaller issues∙2009-10-01 V0.3.2∙Added: Initial releaseVersion Archive(available soon)How to install an older versionAs of Chrome V22 Google has blocked the installation of Chrome extensions that are not hosted in their web store. So if support emails you a iMacros for Chrome extension as beta version please install it this way:How to install:∙Open Chrome, navigate to Tools > Extensions∙Drag and drop the imacros-xyz.crx extension on the extension pageSecurityChrome displays a scary security warning when installing iMacros for Chrome. So we sometimes get questions like:Q: When I click the link to install iMacros, Chrome pops up a warning with this message: "All data on your computer and the websites you visit". Is this actually true or is it an over reaction from Chrome programming?A: iMacros for Chrome needs to read and write the macro files. So technically we need permission to access files on your PC - and thus we could access all files on your PC - just as any other program that you install. Of course, we don't do that. Also, our iMacros for Chrome code is open-source, so everyone can verify it.To summarize, that is a very strong warning from the Chrome team for a simple thing. iMacros for Chrome does not do anything bad or unexpected.Known IssuesPlease report any problem in our user forum. We can only fix issues that you report! Thank you for your help.All issues will be fixed as soon as possible.See AlsoiMacros Community Editions, iMacros for Firefox, Compare all iMacros versions, iMacros7 Version History。
cmake macro 参数

CMake是一个跨评台的自动化构建系统生成器。
它使用简单的语法来管理软件编译过程,并在不同的评台上生成原生的编译系统。
CMake提供了许多功能和选项,其中之一就是macro参数。
在本文中,我们将深入介绍CMake中的macro参数,包括其定义、使用和最佳实践。
1. 什么是CMake中的macro参数?在CMake中,macro参数允许用户定义一组命令序列并在不同的地方进行重复使用。
它类似于函数,但具有一些不同的特性。
macro可以接受任意数量和类型的参数,并且可以像命令一样调用。
2. 如何定义和使用macro参数?要定义一个macro,可以使用如下的语法:```macro(<macro_name> <arg1> <arg2> ... )mands>endmacro()```在这个语法中,`<macro_name>`是宏的名称,`<arg1> <arg2> ...`是参数列表,`mands>`是宏包含的命令序列。
要使用宏,可以使用如下的语法:```<macro_name>(<arg1_value> <arg2_value> ...)```在这个语法中,`<macro_name>`是宏的名称,`<arg1_value><arg2_value> ...`是参数值。
3. 宏参数的最佳实践在使用宏参数时,有一些最佳实践可以帮助提高代码的可读性和可维护性。
应该避免在宏定义中修改全局变量。
这会增加代码的复杂性并增加错误的可能性。
可以使用`${ARGV}`变量来获取所有传递给宏的参数,这样可以避免需要逐个指定参数。
另外,应该为宏参数提供默认值,这样可以使宏更加灵活和易用。
4. 宏参数的高级用法除了基本的定义和使用之外,CMake中的宏参数还可以进行更高级的操作。
icacls的使用命令

icacls的使用命令icacls命令是Windows操作系统中用于管理文件和文件夹权限的命令行工具。
通过icacls命令,可以对特定文件或文件夹设置访问权限、修改权限、查看权限等操作。
本文将详细介绍icacls命令的使用方法和常见参数。
一、icacls命令的基本格式icacls命令的基本格式如下:icacls 文件名/文件夹名 [选项]其中,文件名/文件夹名表示要操作的文件或文件夹的路径,选项是可选的参数,用于指定具体的操作。
二、查看文件或文件夹的权限可以使用icacls命令来查看文件或文件夹的权限。
使用如下命令:icacls 文件名/文件夹名该命令将显示文件或文件夹的详细权限信息,包括所有用户和用户组的权限设置。
三、设置文件或文件夹的权限可以使用icacls命令来设置文件或文件夹的权限。
使用如下命令:icacls 文件名/文件夹名 /grant 用户或用户组:权限其中,文件名/文件夹名表示要设置权限的文件或文件夹的路径,用户或用户组表示要设置权限的用户或用户组,权限表示要设置的具体权限。
例如,要将文件test.txt的完全控制权限授予用户Alice,可以使用以下命令:icacls test.txt /grant Alice:F四、修改文件或文件夹的权限可以使用icacls命令来修改文件或文件夹的权限。
使用如下命令:icacls 文件名/文件夹名 /grant 用户或用户组:新权限其中,文件名/文件夹名表示要修改权限的文件或文件夹的路径,用户或用户组表示要修改权限的用户或用户组,新权限表示要修改的新权限。
例如,要将文件test.txt的读取权限修改为写入权限,可以使用以下命令:icacls test.txt /grant Alice:W五、删除文件或文件夹的权限可以使用icacls命令来删除文件或文件夹的权限。
使用如下命令:icacls 文件名/文件夹名 /remove 用户或用户组其中,文件名/文件夹名表示要删除权限的文件或文件夹的路径,用户或用户组表示要删除权限的用户或用户组。
imacros命令

Imacros命令使用语法一、命令参考1.ADD功能:为变量添加一个值语法:ADD result_var added_value示例1:SET !VAR1 100ADD !VAR1 -20=> Content of !VAR1 is 80示例2:SET !VAR1 HelloADD !VAR1 <SP>World<SP>ADD !VAR1 2010=> Content of !VAR1 is Hello World 2010示例3:ADD !EXTRACT {{!COL1}}2.CLICK语法:CLICK X=n Y=m示例1:URL GOTO=/Automate/TestForm1 ' Use CLICK command to select Apple Pie for dessertCLICK X=316 Y=4533.DISPLAY语法:DISPLAY message_text示例:DISPLAY "Loop is {{!LOOP}}"display #HIDEDISPLAY#Display ""4.EVAL功能:重新运算求出参数的内容示例:SET !VAR1 EVAL("Math.floor(Math.random()*5 + 1);")WAIT SECONDS={{!VAR1}}5.EVENT语法:EVENT TYPE=type [SELECTOR|XPATH]=localizer[BUTTON|POINT|CHAR|KEY]=[button|point|char|key] [MODIFIERS=modifiers]参数:TYPEThe event type to be fired by the command. Allowed values are: Mouse events•MOUSEDOWN,•MOUSEMOVE,•MOUSEUP,•CLICK,•DBLCLICKKeyboard events•KEYDOWN•KEYUP•KEYPRESS示例:URL GOTO=https:///#!/EVENT TYPE=MOUSEDOWNSELECTOR="#preview-svg>svg>svg>svg>foreignObject>DIV" BUTTON=0EVENTS TYPE=MOUSEMOVESELECTOR="#preview-svg>svg>svg>svg>foreignObject>DIV"POINTS="(131,254),(132,254),(134,254),(136,255),(139,256),(142,256),( 147,256),(153,257),(160,257),(169,258),(190,258)"EVENT TYPE=MOUSEMOVE SELECTOR="#containment" POINT="(204,257)"EVENT TYPE=MOUSEUP POINT="(386,254)"6.FILEDELETE语法:FILEDELETE NAME=file_name示例:FILEDELETE NAME=c:\output\mydata.csv7.FILTER语法:FILTER TYPE=IMAGES STATUS=(ON|OFF)Parameters•TYPESpecifies the type of elements to filter. Currently only IMAGES is supported •STATUSSpecifies whether the filter is turned on of off.8.FRAME语法:FRAME (F=n|NAME=id)示例:FRAME F=6TAG POS=1 TYPE=SPAN ATTR=TXT:Select<SP>pathFRAME NAME=contentsTAG POS=1 TYPE=P FORM=NAME:f3 ATTR=TXT:* EXTRACT=TXT9.ONDIALOG语法:ONDIALOG POS=n BUTTON=(OK|YES|NO|CANCEL) [CONTENT=some_content]示例:URL GOTO=/Automate/DialogsONDIALOG POS=1 BUTTON=OK CONTENT=TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:NoFormNameATTR=VALUE:Popup<SP>1ONDIALOG POS=1 BUTTON=OK CONTENT=TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:NoFormNameATTR=VALUE:Ask<SP>me<SP>a<SP>questionWAIT SECONDS=3TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:NoFormNameATTR=VALUE:Change<SP>background<SP>back<SP>to<SP>default<SP>10.ONDOWNLOAD语法:ONDOWNLOAD FOLDER=folder_name FILE=file_name WAIT=[YES|NO] CHECKSUM=[MD5|SHA:hexadecimal_string]示例1:ONDOWNLOAD FOLDER=* FILE=*ONDOWNLOAD FOLDER=C:\MyFiles\ FILE=myDownload.exe ONDOWNLOAD FOLDER=* FILE=+{{!NOW:yymmdd}}ONDOWNLOAD FOLDER=* FILE=* WAIT=YESCHECKSUM=SHA1:3FD97C2EC475731997F7F28CB5C07F3D1A1E820A示例2:‘下载PDF文件URL GOTO=/Automate/PDFDemo ONDOWNLOAD FOLDER=* FILE=+_{{!NOW:yyyymmdd_hhnnss}}TAG POS=1 TYPE=A ATTR=TXT:*View<SP>iMacros<SP>Case* 11.ONERRORDIALOG语法:ONERRORDIALOG BUTTON=(YES|NO) CONTINUE=(YES|NO)12.ONLOGIN语法:ONLOGIN USER=username PASSWORD=password RETRY=[YES|NO] 示例:ONLOGIN USER=username PASSWORD=passwordURL GOTO=13.PAUSE语法:PAUSE如果宏应该等待手动用户输入或进行调试,那么该命令非常有用。
quickmacros语法

quickmacros语法Quick Macros(QM)是一个功能强大的自动化工具,它使用自己的宏语言来编写脚本。
下面是关于Quick Macros语法的一些重要信息:1. 基本语法:Quick Macros的基本语法类似于C语言和其他常见的编程语言。
它使用分号来表示语句的结束,使用大括号来表示代码块。
例如:str s = "Hello, World!";int i = 10;if(i > 5) {。
out s;}。
2. 变量和数据类型,Quick Macros支持整数、浮点数、字符串和布尔值等基本数据类型。
它还允许用户定义自己的数据类型。
3. 函数和命令,Quick Macros提供了丰富的内置函数和命令,用于完成各种任务,例如窗口操作、文件操作、字符串处理等。
用户也可以自定义函数来扩展其功能。
4. 控制结构,Quick Macros支持常见的控制结构,如if语句、循环语句(for、while等)和switch语句,以便实现条件判断和循环操作。
5. 对象和方法,Quick Macros支持面向对象的编程,用户可以创建对象并调用其方法来完成特定的任务。
6. 注释,在Quick Macros中,可以使用双斜杠(//)来添加单行注释,也可以使用/和/来添加多行注释,以便对代码进行说明和解释。
总的来说,Quick Macros的语法相对简单易懂,但功能强大,可以用于自动化各种任务,包括键盘鼠标操作、窗口管理、文件处理等。
希望这些信息能够帮助你更好地了解Quick Macros的语法特点。
imacros教程Form Filling

Form Filling"At the Office of Enrollment Services at Indiana University Bloomington we have been usingiMacros to automate data entry tasks into PeopleSoft... and have saved hundreds of hours of data entry time thus far."Anne Palmer, Indiana University, iMacros Enterprise EditionContents[hide]• 1 Introduction• 2 Variableso 2.1 Built-in variableso 2.2 User-defined Variables• 3 Data Inputo 3.1 Input from Comma Separated Data (CSV) Fileo 3.2 Input from Database• 4 Tabbed Browser• 5 Frames• 6 Fine Tune TAG Commandso 6.1 Wildcards▪ 6.1.1 Example▪ 6.1.1.1 Related forum posts:IntroductionAre you tired of filling out the same form over and over again? Then let iMacros help you. Simply put all data to be input into a very straightforward and easily understandable text file and iMacros can read the data from there and submit it to the web site - completely automatic, without your interaction!The data source can be in either of two different formats: a text file with a list of variables and their values of the form key=value or as a comma separated text file (CSV format). A text file in CSV format can be generated and edited by Microsoft Excel and many other applications.As a rule of thumb the "list of variables" format is recommend if you have many different variables but only one or a few value(s) for each variable (for example, your detailed address data that you use to fill out online forms). The CSV format is most appropriate for use with a few variables withmany different values (for example, a long list of CD's that you want to submit to an auction web site).More advance users might connect directly to databases to retrieve the data.(Related example macros: Demo-Datasource, Demo-Loop-CSV-2Web) (Related example script: Datasource-2-web.vbs, File-2-web.vbs, File-2-web-Method2.vbs, Database-2-web.vbs) Variables(Related example macros: Demo-Datasource, Demo-Slideshow )Variables are, as the name suggests, constructs that allow you to dynamically, usually during runtime, hold different values. This is very helpful when you are trying to follow links that contain changing words or when you want to use the same macro for entering different values into a search engine.The values (content) of all variables in iMacros are accessed by putting two curly brackets around the variable name. The values of !VAR1 is thus accessed by {{!VAR1}}.Variables can be part of anything inside the macro (except the commands themselves). For example, you can add them as part of the ATTR string in a TAG or EXTRACT command or as part of the URL statement:You can assign almost any value to a variable. However, when assigning a value to a variable with SET certain characters need to be escaped or substituted because they imply a certain behaviour to iMacros. When assigning values to variables all whitespaces in the value part must be substituted by <SP> and all newlines must be substituted by <BR>; double curly brackets must be escaped with #NOVAR# ie. #NOVAR#{{. Note this this only applies inside a macro, e. g withthe TAG, SET or ADD commands. If you use the iimSet command of the Scripting Interface, it replaces " " with <SP> and newline with <BR> automatically.There are two kinds of variables in iMacros:Built-in variablesThese variables are used to define certain properties of the macro's behavior, for example the macro timeout value:There are three special built-in variables, !VAR1, !VAR2 and !VAR3 (in the iMacros BRowser and iMacros for Internet Explorer, you can have up to !VAR9 and !VAR0). These variable can be set to anything you like. They are also defined with the SET commandAlternatively, you can prompt the user to input a value:User-defined VariablesThese variables are created during runtime ("on the fly"). There are 3 different ways of creating variables:1. You may use the command line switch -var_MYVAR like inwhich creates the variable ITEM during replay of the macro myMacro and gives it the value 15.2. The second options is to use the iimSet function of the Scripting Interface. In a Visual Basic Script example this would look like:3. Or you may simply use the SET command as inNote that the user-defined variables should not have a prefixed "!". Only the built-in ones do, like e.g. !LOOP.Data InputInput from Comma Separated Data (CSV) FileShort URL to this section(Related example macros: Demo-ReadCSV) (Related example script: CSV-2-web.vbs,Database-2-web.vbs)iMacros allows you to specify a text file with comma separated values (CSV) to be used as input. Imagine, for example, that you want to submit a list of CD's to an online auction. Here is the list of the CD's in the comma separated format:Note: Quotation marks are optional in most cases. They are only required if the value itself contains a comma, or a new line.We now need to tell the iMacros macro where the data input file can be found. For that we use the built-in variable !DATASOURCEIf you do not use any path information (like C:\myPath\) in the !DATASOURCE value the file is assumed to lie in the standard datasources directory, which can be specified in the Paths tab of the Options dialog. The default directory is in the datasources\ directory of your iMacros installation (e.g. C:\Program Files\iMacros\datasources\).Since we want to insert all datasets into the form we need to loop over the macro, each time inserting the next CD. Therefore, we need to tell iMacros in which line of the datasource we currently are. We do this using the built-in variable !DATASOURCE_LINE. By cunningly using the built-in variable !LOOP we let iMacros take care of the counting. And since the first line is just the header, we would like to skip it and start counting from 2:Now we can have the macro fill out the online form with the values from the current CD dataset. We use the built-in variables !COLn, where n represents the number of the columns to put into the form element.During the execution of the macro the constants in parentheses {{..}} are replaced by the value specified in the data sources.Please note that you need to use the "Play (Loop)" button instead of the regular "Play" button if you want to loop through a CSV file. Also don't forget to set the "Max" text box value to the number of the last line you want to reach in your CSV file.Input from Database(Related example macros: Wsh-Submit-2-Web) (Related example script: File-2-web-Method2.vbs, Database-2-web.vbs)This example only works with the Enterprise Edition.iMacros can read data directly from any Windows database using the Scripting Interface and a few lines of code.This example code in Visual Basic Script connects to a Microsoft Access database:Tabbed BrowserUsing Tabs(Related example macros: Demo-Tab )The iMacros Browser [Standard and Enterprise Edition only] includes a tabbed browsing interface that makes managing web sites with multiple open pages a snap. When a web page opens a new window iMacros automatically opens it in a new tab in the background. If the user changes to another tab a TAB command is automatically added during recording.You can close tabs while browsing by right-clicking on the tabs (not the browser window itself!). This will open up a context menu with the options to close the tabs. The following example shows the basic actions you can do with the TAB commandiMacros for Internet Explorer supports tabs in IE 8 and IE 9 (not in Windows XP, though!) Do not forget to enable IE to open popups in tabs (Internet Options in IE Tools menu) if you want to use this feature.FramesFrame in Object TreeiMacros handles pages with frames automatically. It inserts FRAME statements that indicate to which frame the following TAG or similar command refers. Please note that TAG will fail if it is not directed to the correct frame.If the frame has a name, iMacros will use it in the FRAME statement, otherwise its index (the position of the frame in the page's object tree) is used.HintWhen recording in the iMacros Browser or Internet Explorer, use Click Mode = Expert toget the frame number as a comment in the recorded macro. Later you can edit your macro and decide which suits better your needs. Some websites use random names but fixedindexes, in this case it is better to refer to the frame number instead of the default framename.Fine Tune TAG CommandsNormally the TAG commands work the way they are recorded by iMacros, but sometimes you need to manually fine tune them. If an error occurs during replaying a TAG command it might be due to one of the following problems.WildcardsSome web sites are created dynamically from databases and the links contain unique numbers - the so-called session ID - each time you visit a page. While this technique helps the web site owner it poses a problem to iMacros. This is because during recording the session ID, which is often part of links, was written into the macro as part of the TAG command. During replay the session ID is different, thus iMacros does not find the exact link and produces an error. The solution is to replace the changing part of a link (or extraction) with the * symbol, which is read by iMacros as a wildcard. The wildcard causes iMacros to accept any character where the * is placed.ExampleTag line as recorded by iMacros:If you record the same macro a second time you will see that we get the same TAG line except one number - this is the session ID the website is using.Replace the session ID with *:Actually, you could also remove most or all of the static parts of the FORM information as well. Exactly how much you can remove depends on the website. You still need enough information for iMacros to uniquely identify the page element. In our example, the result looks like:or evenNote:TXT:* is not the same as TXT: (without *). If only TXT: is used, this means you are looking for an element where the text attribute is "", if you are using TXT:* this means that the text attribute can have any value (= same as omitting the text attribute altogether). This applies to any attribute, not just TXT.。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Imacros命令使用语法一、命令参考1.ADD功能:为变量添加一个值语法:ADD result_var added_value示例1:SET !VAR1 100ADD !VAR1 -20=> Content of !VAR1 is 80示例2:SET !VAR1 HelloADD !VAR1 <SP>World<SP>ADD !VAR1 2010=> Content of !VAR1 is Hello World 2010示例3:ADD !EXTRACT {{!COL1}}2.CLICK语法:CLICK X=n Y=m示例1:URL GOTO=/Automate/TestForm1 ' Use CLICK command to select Apple Pie for dessertCLICK X=316 Y=4533.DISPLAY语法:DISPLAY message_text示例:DISPLAY "Loop is {{!LOOP}}"display #HIDEDISPLAY#Display ""4.EVAL功能:重新运算求出参数的内容示例:SET !VAR1 EVAL("Math.floor(Math.random()*5 + 1);")WAIT SECONDS={{!VAR1}}5.EVENT语法:EVENT TYPE=type [SELECTOR|XPATH]=localizer[BUTTON|POINT|CHAR|KEY]=[button|point|char|key] [MODIFIERS=modifiers]参数:TYPEThe event type to be fired by the command. Allowed values are: Mouse events•MOUSEDOWN,•MOUSEMOVE,•MOUSEUP,•CLICK,•DBLCLICKKeyboard events•KEYDOWN•KEYUP•KEYPRESS示例:URL GOTO=https:///#!/EVENT TYPE=MOUSEDOWNSELECTOR="#preview-svg>svg>svg>svg>foreignObject>DIV" BUTTON=0EVENTS TYPE=MOUSEMOVESELECTOR="#preview-svg>svg>svg>svg>foreignObject>DIV"POINTS="(131,254),(132,254),(134,254),(136,255),(139,256),(142,256),( 147,256),(153,257),(160,257),(169,258),(190,258)"EVENT TYPE=MOUSEMOVE SELECTOR="#containment" POINT="(204,257)"EVENT TYPE=MOUSEUP POINT="(386,254)"6.FILEDELETE语法:FILEDELETE NAME=file_name示例:FILEDELETE NAME=c:\output\mydata.csv7.FILTER语法:FILTER TYPE=IMAGES STATUS=(ON|OFF)Parameters•TYPESpecifies the type of elements to filter. Currently only IMAGES is supported •STATUSSpecifies whether the filter is turned on of off.8.FRAME语法:FRAME (F=n|NAME=id)示例:FRAME F=6TAG POS=1 TYPE=SPAN ATTR=TXT:Select<SP>pathFRAME NAME=contentsTAG POS=1 TYPE=P FORM=NAME:f3 ATTR=TXT:* EXTRACT=TXT9.ONDIALOG语法:ONDIALOG POS=n BUTTON=(OK|YES|NO|CANCEL) [CONTENT=some_content]示例:URL GOTO=/Automate/DialogsONDIALOG POS=1 BUTTON=OK CONTENT=TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:NoFormNameATTR=VALUE:Popup<SP>1ONDIALOG POS=1 BUTTON=OK CONTENT=TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:NoFormNameATTR=VALUE:Ask<SP>me<SP>a<SP>questionWAIT SECONDS=3TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:NoFormNameATTR=VALUE:Change<SP>background<SP>back<SP>to<SP>default<SP>10.ONDOWNLOAD语法:ONDOWNLOAD FOLDER=folder_name FILE=file_name WAIT=[YES|NO] CHECKSUM=[MD5|SHA:hexadecimal_string]示例1:ONDOWNLOAD FOLDER=* FILE=*ONDOWNLOAD FOLDER=C:\MyFiles\ FILE=myDownload.exe ONDOWNLOAD FOLDER=* FILE=+{{!NOW:yymmdd}}ONDOWNLOAD FOLDER=* FILE=* WAIT=YESCHECKSUM=SHA1:3FD97C2EC475731997F7F28CB5C07F3D1A1E820A示例2:‘下载PDF文件URL GOTO=/Automate/PDFDemo ONDOWNLOAD FOLDER=* FILE=+_{{!NOW:yyyymmdd_hhnnss}}TAG POS=1 TYPE=A ATTR=TXT:*View<SP>iMacros<SP>Case* 11.ONERRORDIALOG语法:ONERRORDIALOG BUTTON=(YES|NO) CONTINUE=(YES|NO)12.ONLOGIN语法:ONLOGIN USER=username PASSWORD=password RETRY=[YES|NO] 示例:ONLOGIN USER=username PASSWORD=passwordURL GOTO=13.PAUSE语法:PAUSE如果宏应该等待手动用户输入或进行调试,那么该命令非常有用。
14.PROMPT语法:PROMPT prompt_text variable_name [default_value]示例:SET !ENCRYPTION NOPROMPT "Please enter your password:" !VAR1TAG POS=1 TYPE=INPUT:PASSWORD FORM=NAME:loginbox ATTR=ID:pass CONTENT={{!VAR1}}15.PROXY语法:PROXY ADDRESS=proxy_URL:port [BYPASS=page_name]示例:PROXY ADDRESS=192.1.8.1:8080PROXY ADDRESS=:8080 BYPASS=*imacros*16.SAVEAS语法:SAVEAS TYPE=(CPL|MHT|HTM|TXT|EXTRACT|BMP|PNG|JPEG) FOLDER=folder_name FILE=file_name示例1:SAVEAS TYPE=MHT FOLDER=* FILE=homepage_currentSAVEAS TYPE=BMP FOLDER=C:\Screenshots FILE=+{{!NOW:ddmmyyyy}} SAVEAS TYPE=EXTRACT FOLDER="C:\\My Macros\\Downloads FILE=*" SAVEAS TYPE=EXTRACT FOLDER=C:\My<SP>Macros\Downloads FILE=*TAG POS=1 TYPE=H1 ATTR=TXT:* EXTRACT=TXTSAVEAS TYPE=CPL FOLDER=d:\reports FILE=report_{{!EXTRACT}}.htm示例2:URL GOTO=/Automate/SaveAsWAIT SECONDS=3URL GOTO=/imacros/'Save the page in all three different formatsSAVEAS TYPE=HTM FOLDER=* FILE=+_{{!NOW:yyyymmdd_hhnnss}} SAVEAS TYPE=TXT FOLDER=* FILE=+_{{!NOW:yyyymmdd_hhnnss}}17.SAVETARGETAS把目标另存URL GOTO=/Automate/SaveTargetAs'Download 1'Define download folder and fileONDOWNLOAD FOLDER=* FILE=+_pdf-file_{{!NOW:yyyymmdd_hhnnss}}'TAG statement, the CONTENT=EVENT:SAVETARGETAS part was added manually after recording TAG POS=1 TYPE=A ATTR=TXT:"Open PDF Document" CONTENT=EVENT:SAVETARGETAS'Download 2ONDOWNLOAD FOLDER=* FILE=+_video-file_{{!NOW:yyyymmdd_hhnnss}}TAG POS=1 TYPE=A ATTR=TXT:"Play Video" CONTENT=EVENT:SAVETARGETAS18.SAVEITEM语法:TAG POS=1 TYPE=INPUT:IMAGE FORM=NAME:frmImpact2 ATTR=ID:mapimg CONTENT=EVENT:SAVEITEMTAG POS=1 TYPE=IMG ATTR=HREF:http://*.jpg CONTENT=EVENT:SAVEITEM 19.SCREENSHOT语法:SCREENSHOT TYPE=(PAGE|BROWSER) FOLDER=folder_name FILE=file_name 示例:URL GOTO=/imacros/home/v9/home.aspSCREENSHOT TYPE=Page FOLDER=* FILE=*SCREENSHOT TYPE=Browser FOLDER=* FILE=*20.SEARCH语法:SEARCH SOURCE=(TXT|REGEXP) IGNORE_CASE=YES EXTRACT=$1示例:URL GOTO=/'Check for GA ObjectSEARCH SOURCE=TXT:"'GoogleAnalyticsObject'"'Check for GA Object, ignore caseSEARCH SOURCE=TXT:"'googleanalyticsobject'" IGNORE_CASE=YES'Use regular expression to extract dataSEARCH SOURCE=REGEXP:"ga\\('create', '([^']+)', ''\\)" EXTRACT="Tracker is $1"'Display extracted dataPROMPT {{!EXTRACT}}21.SET语法:SET var value示例:SET myDelay 10WAIT SECONDS={{myDelay}}SET !VAR1 Hello<SP>World=> Content of !VAR1 is "Hello World".22.STOPWATCH语法:STOPWATCH LABEL=id注意:您需要匹配的一对,因为这个命令返回两个秒表命令之间的差异。