简体   繁体   English

编译除 -o 外没有其他标志的 C 代码

[英]compile C code with no flag other than -o

Im doing an assignment and the requirement instruction say "Your code should compile correctly (no warnings and errors) with no flags other -o. you should compile your code to a debug-able executable without producing any warnings or error messages. (Note that -O and -o are different flags.)"我在做一个任务,需求说明说“你的代码应该正确编译(没有警告和错误),没有其他 -o 标志。你应该将你的代码编译成一个可调试的可执行文件,而不产生任何警告或错误消息。(注意-O 和 -o 是不同的标志。)”

So Im so confused what does the " no flags other -o " means.所以我很困惑“没有其他 -o 标志”是什么意思。 As far as I know, "flag is a general tool for rudimentary signalling and identification, especially in environments where communication is similarly challenging.", so does the requirement mean that we can't use any for loop ?据我所知,“标志是基本信号和识别的通用工具,特别是在通信同样具有挑战性的环境中。”,那么这个要求是否意味着我们不能使用任何 for 循环?

No, the requirement is referring to command-line flags, ie options to the compiler.不,要求是指命令行标志,即编译器的选项。 Eg, assuming gcc, gcc -o foo foo.c .例如,假设 gcc, gcc -o foo foo.c

However, since the program is meant to be debuggable, the requirements are contradictory because creating a debuggable executable requires (for gcc) the -g flag.但是,由于程序是可调试的,因此要求是矛盾的,因为创建可调试的可执行文件需要(对于 gcc) -g标志。

On many compilers, you can control the warning level with flags.在许多编译器上,您可以使用标志来控制警告级别。 The requirement here is to not use those flags, yet raise no warning.这里的要求是不使用这些标志,但不发出警告。

Said differently, you are just asked to write neat and clean C code using no specific extension nor any semi valid constructs (code not conforming to the standard but accepted with warnings by a compiler)换句话说,您只需要使用不使用特定扩展或任何半有效结构(不符合标准但被编译器警告接受的代码)编写整洁干净的C 代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM