Не указатель, не может разыменование - PullRequest
0 голосов
/ 22 марта 2012

Я пишу код на C, где структура передается по ссылке и используется в другой функции

Ниже приводится объявление вызываемой функции:

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

Где limit_record и state_records являются структурами, объявленными как показано ниже:

    struct constraints
    {
       float lower_limit;
       float upper_limit;
    };

Вышеуказанная функция вызывается из другой функции (не из основной) следующим образом:

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

Следующая информация о коде функции Compute:

    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;

Может кто-нибудь, пожалуйста, помогите мне в этом ...

Заранее спасибо

1 Ответ

2 голосов
/ 22 марта 2012

Найдите в своем коде что-то вроде:

#define coefficient

и измените его на:

#define coefficient .42
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...