Good day
我正在尝试在 C++11 项目中使用 C SD 驱动程序/文件系统库 (Keil MDK)。它是由 Keil MDK 5.23 中的 Pack 管理器添加的。我正在使用 ARMCC 5.06u4 进行编译
我收到警告class "_ARM_MCI_STATUS"
没有合适的复制构造函数”,这很奇怪,因为它声明的标头有extern "C" {
.
默认情况下,该包没有将其设置为 C 或 C++ 的选项,但我已手动将该文件添加为 C 文件。还是一个问题。
该结构体在内部声明extern "C" {
as:
typedef volatile struct _ARM_MCI_STATUS {
uint32_t command_active : 1; ///< Command active flag
uint32_t command_timeout : 1; ///< Command timeout flag (cleared on start of next command)
uint32_t command_error : 1; ///< Command error flag (cleared on start of next command)
uint32_t transfer_active : 1; ///< Transfer active flag
uint32_t transfer_timeout : 1; ///< Transfer timeout flag (cleared on start of next command)
uint32_t transfer_error : 1; ///< Transfer error flag (cleared on start of next command)
uint32_t sdio_interrupt : 1; ///< SD I/O Interrupt flag (cleared on start of monitoring)
uint32_t ccs : 1; ///< CCS flag (cleared on start of next command)
uint32_t reserved : 24;
} ARM_MCI_STATUS;
当结构体在以下位置返回时会出现问题:
static ARM_MCI_STATUS GetStatus (MCI_RESOURCES *mci) {
return mci->info->status;
}
Where status
被声明为ARM_MCI_STATUS status;
。我不明白为什么这应该成为一个问题。
如果我在没有 --cpp 的情况下编译,那么它编译时不会出现问题。
有什么建议么?
只因为你的struct
被标记extern "C"
并不意味着它不会仍然被编译为 C++ 代码。
这意味着return mci->info->status;
调用隐式生成的复制构造函数。
因为_ARM_MCI_STATUS
被标记volatile
,它的成员是,这意味着默认的复制构造函数需要T&
无法绑定到它传递的易失性左值引用。
这在c首选项解释:
否则,隐式声明的复制构造函数是 T::T(T&)。 (笔记
由于这些规则,隐式声明的复制构造函数
无法绑定到易失性左值参数。)
而且在实际标准中(只是很难找到正确的条款,但它就在那里)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)