Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning: ISO C forbids an empty translation unit

Tags:

c

macros

In a header file I have the following code which gives me the error in the title, while trying to link.

#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 
like image 842
IamTrent Avatar asked Oct 24 '14 03:10

IamTrent


1 Answers

gcc when compiled with -pedantic reports a diagnostic when the translation unit is empty as it is requested by the C Standard. To make gcc happy, you can add a dummy typedef in the empty .c file:

typedef int make_iso_compilers_happy;

or

extern int make_iso_compilers_happy;
like image 197
ouah Avatar answered Nov 16 '22 01:11

ouah