警告:ISO C禁止空翻译单元

Iam*_*ent 8 c macros

在头文件中,我有以下代码,它在尝试链接时给出了标题中的错误.

#ifndef BOOLEAN_H
#define BOOLEAN_H

#ifndef FALSE
#define FALSE 0
#endif

#ifndef TRUE
#define TRUE !FALSE
#endif

#endif

indicating the error occurs in the line of the last #endif 
Run Code Online (Sandbox Code Playgroud)

oua*_*uah 24

gcc当使用-pedanticC标准请求翻译单元为空时,使用报告编译诊断时.为了gcc开心,你可以typedef在空.c文件中添加一个虚拟:

typedef int make_iso_compilers_happy;
Run Code Online (Sandbox Code Playgroud)

要么

extern int make_iso_compilers_happy;
Run Code Online (Sandbox Code Playgroud)

  • 我有兴趣知道为什么 ISO C 禁止空翻译单元 (5认同)