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

oldnavy picture oldnavy · Dec 9, 2013 · Viewed 21.6k times · Source

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?

Answer

Klas Lindbäck picture Klas Lindbäck · Dec 9, 2013

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).