Tag Archives: C Language error

C Language error: two or more data types in declaration specifiers

Libmemcached encountered an error during compilation:

./config.h:632:15: error: two or more data types in declaration specifiers
 #define off_t long int
               ^
./config.h:632:20: error: two or more data types in declaration specifiers
 #define off_t long int
                    ^
./config.h:658:17: error: two or more data types in declaration specifiers
 #define ssize_t int

Since config. H is generated through the automake tool, I don’t know where to find the problem for a while
first write a try. C file:

#define off_t long int
#define ssize_it int
int main() {
	return 1;
}

Can be compiled
multiple attempts have found that it is related to the order of #define. If #define off_ T long int in #define < stdxx.h> Before, an error will be reported, otherwise no error will be reported
via G + + - E - P try. C > XX , you can see:

#define long int __off_t
#define __off_t off_t

If#define off_t long intis ahead of stdxx.h,then use long int to replace off_t:

#define long int __off_t
#define __off_t long int

A loop occurs, so an error will be reported
and if #define off_ T long int after stdxx. H
because you already have #typedef__ off_ t off_ T without execution

In addition, it is found that #include “A.H” can also be used as #include & lt; a.h>, Previously, it was thought that local. H files could only be imported with “” instead of & lt& gt;, Now it is found that with GCC - I. , the directory with – I and include can be used with & lt& gt; Import local H files.

In addition, G + + can get preprocessed output in – E – P X.C, that is, a. CC file. The extern "C" {...} requires that the precompiled output must be compiled by G + +.