In the standard library (glibc) I see functions defined with leading double underscores, such as __mmap
in sys/mman.h
. What is the purpose? And how can we still call a function mmap
which doesn't seem to be declared anywhere. I mean we include sys/mman.h
for that, but sys/mman.h
doesn't declare mmap
, it declares only __mmap
.
From GNU's manual:
In addition to the names documented in this manual, reserved names include all external identifiers (global functions and variables) that begin with an underscore (‘_’) and all identifiers regardless of use that begin with either two underscores or an underscore followed by a capital letter are reserved names. This is so that the library and header files can define functions, variables, and macros for internal purposes without risk of conflict with names in user programs.
This is a convention which is also used by C and C++ vendors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With