我正在从旧的 gcc(3.x) 切换到 4.9.2,但我遇到了一些编译问题:
if (ROWID_IS_NULL(&pSumItem->getRowId()))
getRowId()
定义为:
rowid_t SumItem::getRowId()
{
return row_id;
}
宏定义为:
#define ROWID_IS_NULL(a) \
((a)->key == 0 && (a)->ip_addr == 0)
新代码已经使用运算符重载来进行计算,但是仍然有很多使用非标准技术的旧代码。是否可以在不更改代码的情况下解决此问题?
错误信息:
error: taking address of temporary [-fpermissive]
编辑:不改代码的意思
我想保持这条线正常工作
if (ROWID_IS_NULL(&pSumItem->getRowId()))
最佳答案
我不知道您希望“不更改代码”部分走多远。显然,无论应用何种修复,都会以某种方式改变它们。
这将是简单的修复,methinks:
static inline bool ROWID_IS_NULL(const rowid_t &id) {
return(id.key == 0 && id.ip_addr == 0);
}
不过,不可否认,这需要您在调用 ROWID_IS_NULL
时删除显式的 &
运算符。
关于c++ - 修复错误 : taking address of temporary without changing codes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29738908/