该程序既不是有效的 C 程序也不是无效的 C 程序。但是,据我了解,它甚至不能是一个程序,它被定义为供处理单元计算的指令序列。
代码是:
就是这样。作者alleges :
Some C compilers will compile an empty file into a program that does nothing. But even if your compiler can't, the build instructions supplied with this entry will produce an executable file. On most systems, the stdout from the executable will exactly match original source.
我不买账。 编译 将成功,不会产生任何指令。但是,链接 将失败,因为没有要调用的 main
符号。如果它可以运行,那么这个技巧就会奏效,因为它不会输出任何内容,而且源代码实际上什么也不包含。
那么,这个程序
怎么可能(从字面上看,在什么环境下)被认为是一个有效的 self 复制程序?
注意:它已被 IOCCC 接受。
最佳答案
注意这一行很重要:
But even if your compiler can't, the build instructions supplied with this entry will produce an executable file.
有关实际构建说明,请参阅 makefile:
smr: smr.c
@${RM} -rf smr
${CP} smr.c smr
${CHMOD} +x smr
简单地说,这实际上只是创建了一个设置了可执行位的空文件,当然,它什么都不做。
关于c - 这个程序怎么可能有意义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28141622/