Here is my dead simple dummy code:
#include <errno.h> int main(void) { errno_t e; return 0; }
What surprisingly causes this error:
main.c:5:5: error: use of undeclared identifier 'errno_t' errno_t x; ^
I began to follow the tracks: when the compiler sees inclusions <...> , it will first look at /usr/include , where, of course, it found the errno.h file. In fact, there is one line in it, in addition to the comment on the license:
#include <sys/errno.h>
Now, with /usr/include/sys in errno.h , I found the following lines:
#include <sys/cdefs.h> #if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1 #include <sys/_types/_errno_t.h> #endif
And in /usr/include/_types in _errno_t.h I found this:
typedef int errno_t;
So it looks like it is, and it is an alias of the integer type and part of errno.h - as it should be.
Then why is it not turned on? Why does the compiler raise an undeclared identifier error?
Thanks in advance!
RELATED INFORMATION:
Compiler: Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)` Compiler flags: -std=c11 -I/usr/include/sys -I/usr/local/include
The macro variable __STDC_WANT_LIB_EXT1__ will be defined in /usr/include/sys in cdefs.h in the following lines:
#if !defined(__STDC_WANT_LIB_EXT1__) && !defined(__STRICT_ANSI__) && __DARWIN_C_LEVEL >= __DARWIN_C_FULL #define __STDC_WANT_LIB_EXT1__ 1 #endif
UPDATE:
As @PaulR said in the comments section: if I -std=c11 , it compiles. This is just as surprising as the error associated with enabling the flag. Therefore, I am spreading this question to the question:
Is errno_t part of the C11 standard, or why is it not included when the standard is specified for the compiler?
c compiler-construction include clang errno
Peter Varo
source share