C++ 中 extern "C"的问题
各位好:
我这样用
extern "C"
{
const IID IID_IC;
const CLSID CLSID_Component3;
};
和
这样用:
extern "C" const IID IID_IC;
extern "C" const CLSID CLSID_Component3;
如果是一般的使用,2者都能编译通过并且能够运行。
但是当我使用了智能指针之后。
VC9.0 报一个错误Compiler Error C2970:
摘自MSDN:
You cannot use the name or address of a static variable as a template argument. The template class expects a const value that can be evaluated at compile time.
意思大概就是说模板需要的是一个常量,而不接收static的变量。
我跟踪代码之后,发现如果是第一种情况的话,
IID_IC的类型就变成了static const IID。
问题:
为什么加了作用域之后IID_IC变成了static类型的。
谁能帮我解疑么?分不多,尽量给。