在GCC中,我能够做到这一点:
(CachedPath){ino}
inode->data = (struct Data)DATA_INIT;
where:
struct CachedPath
{
Ino ino;
};
typedef int8_t Depth;
struct Data
{
Offset size;
Blkno root;
Depth depth;
};
#define DATA_INIT {0, -1, 0}
对于这种类型的强制转换,MSVC会给出以下错误提示:
error C2143: syntax error : missing ';' before '{'
如何在MSVC中实现这个功能?需要注意的是,该代码已从C99转换而来,在C99中我使用了指定初始化器,然后类似地进行了转换。如果能够解释C99和MSVC/GCC C++实现之间这些不同特性的关系,将不胜感激。