Namespaces in C
问题 Is there a way to (ab)use the C preprocessor to emulate namespaces in C ? I'm thinking something along these lines: #define NAMESPACE name_of_ns some_function() { some_other_function(); } This would get translated to: name_of_ns_some_function() { name_of_ns_some_other_function(); } 回答1: When using namespace prefixes, I normally add macros for the shortened names which can be activated via #define NAMESPACE_SHORT_NAMES before inclusion of the header. A header foobar.h might look like this: //