Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In which header file are EINVAL, ENOMEM, etc. defined in Linux?

Tags:

c

linux

errno

It’s said that the error numbers like EINVAL, ENOMEM, etc. are defined in errno.h, but I can’t find them in errno.h, I also searched some directories under /usr/include, still can’t find them. I can use these macros without any issue in my C code. Anyone can tell me where are them?

like image 424
oldnavy Avatar asked Dec 09 '13 15:12

oldnavy


2 Answers

It's up to the implementation of the standard C library.

All that is certain is that <errno.h> is the top-level header that application code should use.

One way of figuring out is to trace an invocation of the compiler.

like image 139
unwind Avatar answered Sep 29 '22 04:09

unwind


It is defined either directly in errno.h or in a file included (directly or indirectly) by errno.h.

I searched for it using the following command:

find /usr/include | xargs grep ENOMEM | grep '#define'

and I found a match in /usr/include/asm-generic/errno-base.h in my linux (RHEL 6).

like image 27
Klas Lindbäck Avatar answered Sep 29 '22 03:09

Klas Lindbäck