【发布时间】:2016-12-29 16:24:11
【问题描述】:
我有下面的函数,它似乎可以正常工作,但是当通过测试程序运行程序时,我得到了错误:解析错误:[int xSwapped = ((255
int dl15(int x, int n, int m){
// calculates shifts, create mask to shift, combine result
// get number of bytes needed to shift, multiplying by 8
// get Masks by shifting 0xff and shift amount
// shift bits to required position
// combine results
int nShift = n<< 3;
int mShift = m<< 3;
int nMask = x & (255 << nShift);
int mMask = x & (255 << mShift);
nMask = 255 & (nMask >> nShift);
mMask = 255 & (mMask >> mShift);
nMask = nMask << mShift;
mMask = mMask << nShift;
int xSwapped = ((255 << nShift) | (255 << mShift));
return (~xSwapped & x) | nMask | mMask;
}
不确定我缺少什么,谢谢。
【问题讨论】:
-
你使用 MSVC(或 C89 编译器)吗?
-
@BLUEPIXY 不,不是在 Windows 上,测试人员使用 MIT CILK 组的 ANSI C 编译器
-
如果使用 GCC,请使用
-std=c99选项。或该行移至int mShift = m<< 3;之后
标签: c parsing parse-error