How does libc provide functions with two names?

后端 未结 2 680
广开言路
广开言路 2020-12-21 02:17

Before the advent of direct binding (-B direct) libc provided many functions with two names. For example, getpwent() and _getpwent().

2条回答
  •  爱一瞬间的悲伤
    2020-12-21 03:05

    getpwent() implementation just calls _getpwent() simple as that. The reason this is done is to hide some functionality from function calls and to avoid something called namespace pollution. This way you can create a sort of abstraction that allows you to hide things from the user. Also leading underscore and double underscore are system reserved and are backups to make sure that you don't override something such as in macro definitions.

提交回复
热议问题