看起来在C++ extern
(NOT后跟一个语言链接字符串文字)在名称空间范围(Difference between declaration of function with extern and without it)上的函数声明没有区别。但是它对块范围函数声明有什么影响吗?或者是没有extern
的本地函数声明总是等于extern
?函数的本地/块范围声明与没有它的函数的区别
namespace {
void f() {
extern void g(); // has external linkage
g();
}
void f2() {
void g(); // always the same, as if, without extern
g();
}
}
谢谢!
为什么要在函数内声明一个函数?你认为它有什么作用? –
与extern相反的是static - 'static void g(); //内部联动“。 –
@underscore_d检出http://stackoverflow.com/questions/1034606/is-there-any-use-for-local-function-declarations – EulersRainbow