C ++复制库中的随机错误

时间:2017-04-28 16:38:08

标签: c++

我将Big Int Library复制到我的代码中,其中一个类中有随机错误。 (代码较旧)

我的一个错误是在一个define语句中,并不确定这些是如何工作的。 一切都在“tmpthis”之下是错误的。

#define DTRT_ALIASED(cond, op) \
if (cond) {\

    BigUnsigned tmpThis; 
    tmpThis.op; //Error: no storage class or type specifier
    *this = tmpThis; //Error: *this expected an identifier Error: No suitable conversion from "BigUnsigned" to "int" exists.
    return; // Error: expected a declaration
} \

最重要的是,有一些随机的if和for语句带有错误“预期声明”和一些带有错误“no storage class or type specifier”的变量

注意:这些随机错误也有不是错误的情况,也不一致。

1 个答案:

答案 0 :(得分:0)

对宏的简单修复是:

#define DTRT_ALIASED(cond, op) \
    if (cond) { \
        BigUnsigned tmpThis; \
        tmpThis.op; \
        *this = tmpThis; \
        return; \
    }

如果在op中对tmpThis.op的引用对编译器有意义,则在没有返回值的函数中使用时,这有可能进行编译。它有点特殊(和有限)代码,但它可能有用。