求解extern "C"
本帖最后由 zyouhua83 于 2012-12-10 14:25:53 编辑
#ifndef MyTest__h__
#define MyTest__h__
#ifdef __cplusplus
extern "C" { //...........1处是否有意义
#endif
typedef struct IMyTest IMyTest;
typedef void (*_setMyTest_t)(IMyTest * nMyTest);
#ifdef __cplusplus
}
#endif
#endif // MyTest-_h__
#ifndef MyTest_h__
#define MyTest_h__
#ifdef _MSC_VER
#pragma pack(push,1)
#endif
#ifdef __cplusplus
extern "C" { //..........2处是否有意义
#endif
struct IMyTest
{
_setMyTest_t mSetMyTest;
void * mMyTest;
}__pack;
#ifdef __cplusplus
}
#endif
#ifdef _MSC_VER
#pragma pack(pop)
#endif
#endif // MyTest_h__
求解1和2处是否有意义
[解决办法]
对类(结构)名无意义
对函数类型有意义
$7.5/1
All function types, function names with external linkage, and variable names with external linkage have a language linkage. ...
对类(结构)成员无意义
$7.5/4
... A C language linkage is ignored in determining the language linkage of the names of class
members and the function type of class member functions.
如上都是2011标准,与2003标准一致,没有实质变化,只是表述更具体