GCC,命令行上的-&&是什么意思?

Wei JingNing

我执行这样的命令

echo 'int main(){printf("%lu\n",sizeof(void));}' | gcc -xc  -w -&& ./a.out

并可以得到结果:1.。但是即使在搜索手册页和google!之后,我也无法弄清-&&的含义。并且我尝试在没有-&&选项的情况下执行它。这将是这样的错误:

./a.out:1: error: stray ‘\317’ in program
./a.out:1: error: stray ‘\372’ in program
./a.out:1: error: stray ‘\355’ in program
./a.out:1: error: stray ‘\376’ in program
./a.out:1: error: stray ‘\7’ in program
./a.out:1: error: stray ‘\1’ in program
./a.out:1: error: stray ‘\3’ in program
./a.out:1: error: stray ‘\200’ in program
./a.out:1: error: stray ‘\2’ in program
./a.out:1: error: stray ‘\16’ in program
./a.out:1: error: expected identifier or ‘(’ before numeric constant
./a.out:1: error: stray ‘\6’ in program
./a.out:1: error: stray ‘\205’ in program
./a.out:1: error: stray ‘\31’ in program
./a.out:1: error: stray ‘\1’ in program
./a.out:1: error: stray ‘\31’ in program
./a.out:1: error: stray ‘\2’ in program

......

谁知道选项的含义?

用户名

-&&Shell不会将其解释为单个令牌,而是将其解释为两个单独的令牌:-&&所述-令牌没有特殊意义的壳和作为参数传递给被传递gcc,以读取来自标准输入的源,其将其解释为一个指令。&&是在and子句中连接两个命令的shell运算符仅当)成功完成后才A && B执行Ba.outAecho ... | gcc ...

使用gcc ... && ./a.out而不是更简单的方法gcc ...; ./a.outa.out仅在编译成功后才运行,以防止过时的a.out执行。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章