使用前的 C 声明

标签 c

C 中的所有标识符在使用前都需要声明,但我找不到它在 C99 标准中表示的位置。

我觉得也是指宏定义,不过定义的只是宏展开顺序。

最佳答案

C99:TC3 6.5.1 §2,脚注 79 明确指出:

Thus, an undeclared identifier is a violation of the syntax.

结合 6.2.1 §5:

Unless explicitly stated otherwise, [...] it [ie an identifier] refers to the entity in the relevant name space whose declaration is visible at the point the identifier occurs.

和§7:

[...] Any other identifier has scope that begins just after the completion of its declarator.

关于使用前的 C 声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4804844/

相关文章:

c - 尝试测量 C 中函数的执行时间时得到 0

c++ - 从另一个进程中获取内存

c - 如何确保不同系统上的 float 相同?

c++ - 从源代码构建的 Clang 编译 C 但不编译 C++ 代码

c - 用字符串切换

c - 依次填充缓冲区

c - 使用 C 保留文件中的最后四个 fwrite()

将 `ip tuntap add` system() 调用转换为 C 代码

java - 您如何用 Java 写入磁盘(通过刷新)并保持性能?

c - C中是否需要typedef?