Why doesn't ANSI C have namespaces?

前端 未结 9 1655
無奈伤痛
無奈伤痛 2020-11-27 10:02

Having namespaces seems like no-brainer for most languages. But as far as I can tell, ANSI C doesn\'t support it. Why not? Any plans to include it in a future standard?

9条回答
  •  無奈伤痛
    2020-11-27 10:30

    Historically, C compilers don't mangle names (they do on Windows, but the mangling for the cdecl calling convention consists of only adding an underscore prefix).

    This makes it easy to use C libraries from other languages (including assembler) and is one of the reasons why you often see extern "C" wrappers for C++ APIs.

提交回复
热议问题