2012-03-22 77 views
0

荫C编写代码,其中结构被引用传递,在另一个函数不是指针,无法解引用

以下是用于被调用的函数声明:

float Compute(float input, struct constraints* limits_record, struct constraints* state_record); 

凡limits_record和state_records两者结构声明如下:

struct constraints 
    { 
     float lower_limit; 
     float upper_limit; 
    }; 

上述功能正在从另一个功能(而不是从主)如下称为:

autotrim_out=Compute(inp, &limit, &state); 

按照有关计算函数代码的细节:

float Compute(float input, struct constraints* limits_record, struct constraints* state_record) 
    { 
     float tmp_lim; 
     float tmp_intgr; 
     tmp_intgr = coefficient * (input + state_record->lower_limit) + state_record->upper_limit; 
     if (tmp_intgr < limits_record->lower_limit) 
      tmp_lim = limits_record->lower_limit ; 
     else if(tmp_intgr > limits_record->upper_limit) 
      tmp_lim = limits_record->upper_limit; 
     else 
      tmp_lim = tmp_intgr; 

     state_record->upper_limit = tmp_lim; 
     state_record->lower_limit = input ; 

     return(tmp_lim) ; 
    } 

在编译上面的代码给错误“不是指针,不能顺从”就行了

tmp_intgr = coefficient * (input + state_record->lower_limit) + state_record->upper_limit; 

可有人请帮我这个...

在此先感谢

+3

至于神秘的语法错误一般建议:分裂线或表达成小块,直到你明白错误。 – 2012-03-22 05:43:11

+7

问题出在您未向我们显示的某些代码中。我复制并粘贴你的代码并将其编译到我的系统上;一旦我添加了“系数”的声明,它就会无误地编译。向我们展示一个代表问题的完整自包含源文件。 – 2012-03-22 05:46:02

+1

你发布的内容绝对没有错 - 它对我来说看起来不错,它在MSVC下编译得很好。拿Lars Wirzenius - 把表情分解成更小的部分,直到你明白错误。 – paulsm4 2012-03-22 05:52:36

回答

2

查找东西在你的代码,如:

#define coefficient 

并将其更改为:

#define coefficient .42