Firas 于 2014.10.12 23:59 提问

77: error: expected unqualified-id before '^' token
``````#define TO_SIGNED(x)    ((signed)(x))
class BigInteger{
protected:
unsigned* array;

BigInteger(unsigned*const theArray){
array = theArray;
}

inline unsigned* getArray(){
if(this == BigIntegerNull)
#ifdef _EXCEPTION_H_
throw NullPointerException();
#else
return NullArray;
#endif
return array;
}

BigInteger expand(unsigned newSize, bool extendSign){
if(getArray() == NullArray){
BigInteger n(NullArray);
return n;
}
if(newSize <= array[0]) return *(new BigInteger(*this));
BigInteger nbi(new unsigned[newSize+1]);
register unsigned i;
for(i = 0; i <= array[0]; i++) nbi.array[i] = array[i];
if(extendSign && TO_SIGNED(array[array[0]]) < 0){
for(; i <= newSize; i++) nbi.array[i] = -1;
}else{
for(; i <= newSize; i++) nbi.array[i] = 0;
}
return nbi;
}
public:

static BigInteger*const BigIntegerNull;
static unsigned*const NullArray;

BigInteger(const BigInteger& origin){
#ifdef _EXCEPTION_H_
if(origin.getArray() == NullArray)
throw NullPointerException();
#endif
register unsigned size = origin.array[0]+1;
array = new unsigned[size];
do{
--size;
array[size] = origin.array[size];
}while(size > 0);
}

BigInteger _xor(BigInteger bi, bool extendSign){
if(getArray() == NullArray || bi.getArray() == NullArray){
BigInteger n(NullArray);
return n;
}
register unsigned i;

if(array[0] <= bi.array[0]){
for(i = array[0]; i > 0; i--) array[i] &= bi.array[i];
}else{
for(i = 1; i <= bi.array[0]; i++){
array[i] ^= bi.array[i];
}
if(extendSign && TO_SIGNED(bi.array[bi.array[0]]) < 0){
for(; i <= array[0]; i++){
array[i] = -1;  // or -1
}
}
}

return *this;
}

BigInteger xor(BigInteger bi, bool extendSign){    // 编译器指示错误的行
BigInteger n(NullArray);
if(getArray() == NullArray || bi.getArray() == NullArray){
return n;
}
register unsigned i;
if(array[0] <= bi.array[0]){
n = this->expand(bi.array[0], extendSign);
for(i = array[0]; i > 0; i--){
n.array[i] ^= bi.array[i];
}
if(extendSign && TO_SIGNED(bi.array[bi.array[0]]) < 0){
for(; i <= bi.array[0]; i++){
n.array[i] = ~bi.array[i];  // xor -1
}
}else{
for(; i <= bi.array[0]; i++){
n.array[i] = bi.array[i];   // xor 0
}
}
}else{
n = *(new BigInteger(*this));
for(i = 1; i <= bi.array[0]; i++){
n.array[i] ^= bi.array[i];
}
if(extendSign && TO_SIGNED(bi.array[bi.array[0]]) < 0){
for(; i <= array[0]; i++){
n.array[i] = ~array[i]; // xor -1
}
}
}
return n;
}
};
BigInteger*const BigInteger::BigIntegerNull = reinterpret_cast<BigInteger*>(0);
unsigned*const BigInteger::NullArray = reinterpret_cast<unsigned*>(0);
``````

expected unqualified-id before '(' token

error: expected unqualified-id before ‘}’ token
error: expected unqualified-id before ‘}’ token 原因： C++ 头文件定义中类的定义后没有加分号“；”   特此共享
linux error: expected unqualified-id before '[' token 报错系列
make编译时常会如下系列错误(使用的是调用厂商提供的h文件，其中的定义有的是和自己工程有同名的现象)   error: expected unqualified-id before '[' token error: expected unqualified-id before ';' token   对同名的最好是区分开，比如windows中用 HWND，在linux里用HWND_LL
error: expected unqualified-id before ‘decltype’

c++config.h:43: error: expected unqualified-id before 'namespace'解决

expected unqualified-id before ....的问题

expected unqualified-id before 'int'
Qt 5.1 升级后编译之前的代码，发现很诡异的问题。  error: expected unqualified-id before 'int'  error: expected '}' before 'int'  error: expected ',' or ';' before 'int'  error: expected declaration before '}
g++编译错误:expected unqualified-id before ‘using’

expected unqualified-id before numeric constant
ok!  如果你的问题正是此标题，那么下面看看我的错误是怎么产生的： 1、我在弄一个redis client 库，下载:https://github.com/nekipelov/redisclient 2、这个库使用boost 3、这个库里有CMakeLists.txt，但是我还是自己写了个makefile 那么问题来了，当我make的时候出现了上述的错误，引起问