Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meaning of double underscore in the beginning

Tags:

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.

like image 635
pythonic Avatar asked May 21 '12 14:05

pythonic


1 Answers

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.

like image 148
dirkgently Avatar answered Nov 13 '22 11:11

dirkgently