
namespace n { voID f() { voID another_function(); }} 应该在命名空间n或外部定义函数another_function吗? VS 2012(与November CTP一起)说它应该在外面,Mac上的GCC 4.7.2说应该在里面.如果我做错了,我会从链接器中得到未定义的符号错误.
我一般都相信GCC更符合标准,但这是C,你永远不能确定.
解决方法 C 11 3.5(以及C 03)7 When a block scope declaration of an entity with linkage is not found
to refer to some other declaration,then that entity is a member of
the innermost enclosing namespace. However such a declaration does not
introduce the member name in its namespace scope.
示例中的声明声明了n :: another_function.
总结以上是内存溢出为你收集整理的c – 命名空间内的本地函数声明全部内容,希望文章能够帮你解决c – 命名空间内的本地函数声明所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)