Raghu
Raghu

Reputation: 35

In C, why certain function name prefix of "_ _" (double underscore)

I am reading the source code of open-iscsi. In this source files I see few functions start with prefix "__". Whats the reason behind naming a function with double underscore as prefix in general in C language?

Example: In the file usr/iscsi_sysfs.c, the function name static int __get_host_no_from_hwaddress(void *data, struct host_info *info)

Thanks for reading the post

Upvotes: 1

Views: 490

Answers (1)

AlexD
AlexD

Reputation: 32596

These are reserved identifiers. Using them guarentees no naming collisions with user's code (assuming the users follow the convention).

7.1.3 Reserved identifiers
....
All identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any use.

Such names should not appear in third-party libraries, see @M.M.'s comment.

Upvotes: 2

Related Questions