未实现:C ++中出乎意料的ltgt_expr

时间:2015-03-14 17:57:36

标签: c++ unix cmake makefile

我正在尝试构建一个由以前的学生用C ++编写的程序。我使用ccmake然后使用make来构建程序。但是,在我点击make后,我收到错误消息:

/workspace/arthur/Project/src/DirectoryName/name.cpp: In member function     ‘void seed::Sweep(Datareg3&)’:
/workspace/arthur/Project/src/DirectoryName/name.cpp: sorry, unimplemented: unexpected ast of kind ltgt_expr
/workspace/arthur/Project/src/DirectoryName/name.cpp:confused by earlier errors, bailing out
make[2]: *** .. Error 1
make[1]: *** ..Error 2

错误发生在下面代码的最后一行:

此源文件的代码如下:

#define sgn(x) ((x)>0 ? 1 : ((x)<0?-1:0))

void seed::Sweep(Datareg3& reg3)
{
    u_int i, j, k;
    Range resp;
    float min, max, t;
    float gradz;
    float grad1xa, grad1xb;
    float grad1ya, grad1yb;
    float grad2xa, grad2xb;
    float grad2ya, grad2yb;
    int keepflat, *keepflat_y;
    keepflat_y = (int*)malloc(sizeof(int)*reg3.dim[0]);
    for(k=0; k<reg3.dim[2]-1; k++)
    {
        ..
        for(j=0; j<reg3.dim[1]-1; j++)
        {
            keepflat = 1;
            for(i=0; i<reg3.dim[0]-1; i++)
            {
                resp.MakeEmpty();

                // top
                if(i == reg3.dim[0]-2)
                {
                    if(keepflat && keepflat_y[i])
                    {
                        // reached end at a flat.. add the edge values
                        min = max = reg3.getValue(i+1,j,k);
                        if((t=reg3.getValue(i+1,j,k+1)) < min)
                        {
                            min = t;
                        }
                        if(t > max)
                        {
                            max = t;
                        }
                        resp += Range(min,max);
                    }

                    // do we need to set keepflat_y[i]?
                    gradz = reg3.getValue(i,j+1,k+1) -
                            reg3.getValue(i,j+1,k);
                    grad2xa = reg3.getValue(i+1,j+1,k+1) - reg3.getValue(i,j+1,k+1);
                    grad2xb = reg3.getValue(i+1,j+1,k)   - reg3.getValue(i,j+1,k);
                    grad2ya = reg3.getValue(i,j+1,k+1) - reg3.getValue(i,j,k+1);
                    grad2yb = reg3.getValue(i,j+1,k)   - reg3.getValue(i,j,k);
                    keepflat_y[i] = (sgn(gradz) != 0 &&
                                     ((sgn(gradz) == -sgn(grad2xa) && sgn(gradz) == sgn(grad2ya))
                                      ||
                                      (sgn(gradz) == -sgn(grad2xb) && sgn(gradz) == sgn(grad2yb)))); 
//error occurs AT THIS LINE

我之前和之后都没有看过这个错误,当我尝试谷歌搜索它时,我得到的结果很少。有谁知道如何处理这个?

1 个答案:

答案 0 :(得分:0)

我建议你简化表达式以帮助编译器:

const int sgn_gradz = sgn(gradz);
keepflat_y[i] = (sgn_gradz != 0
                 && (    (sgn_gradz == -sgn(grad2xa) && sgn_gradz == sgn(grad2ya))
                      || (sgn_gradz == -sgn(grad2xb) && sgn_gradz == sgn(grad2yb))
                    )
                ); 

另一个想法是使用临时bool变量将复合表达式拆分为更小的表达式:

const bool sgn_gradz_eq_neg_sgn_grad2xa = sgn_gradz == -sgn(grad2xa);
keepflat_y[i] = (sgn_gradz != 0
                 && ( sgn_gradz_eq_neg_sgn_grad2xa   && sgn_gradz == sgn(grad2ya))
                      || (sgn_gradz == -sgn(grad2xb) && sgn_gradz == sgn(grad2yb))
                    )
                ); 

通过使用临时变量将复合表达式拆分为较小的表达式,编译器将在特定表达式而不是整行上生成错误。

要做的另一项工作是验证sgn函数在此翻译单元中是否有声明。