c - 这个程序怎么可能有意义?

标签 c

该程序既不是有效的 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/

相关文章:

c - 在C中将字符串存储在数组中

c - 在 C 中,为什么从套接字读取会导致 printw 出现段错误?

c - 在字符串中搜索子字符串

c++ - 确定 HWND 是否代表顶级窗口的最佳方法是什么?

c - 是否有任何 C 编译器可以向您展示 asm 中的链接程序?

c - 在#define 函数宏中使用符号名称作为字符串文字

C - 如何按子字符串拆分字符串

c - 为什么野指针是用共享库虚拟地址初始化的?

使用 C 与 mbed 通信

iphone - Object-C调用C函数读取文件