Using struct variables in functions - Conflicting types
Asked 07 September, 2021
Viewed 2.3K times
  • 57
Votes

i'm trying to pass struct variables to a function, but i receive:

error: conflicting types for 'referenzspannung'
void referenzspannung(struct ADMESSUNG *mess) {
     ^~~~~~~~~~~~~~~~

In my measure.h i wrote the prototype:

void referenzspannung(struct ADMESSUNG *mess);

and in the measure.c there is the struct+function:

struct ADMESSUNG {
    unsigned long Coderef;
    double Uref;
    double Stcal;
    double Offset;
    unsigned long Temperaturcode;
    double Temperaturavin;
    double RTD;
    double R;
    double Tempwert;
    unsigned long Phcode;
    double Phavin;
    double Stprobe;
    double PHWert;
};
struct ADMESSUNG mess;
void referenzspannung(struct ADMESSUNG *mess) {
    AD7793_SetIntReference(AD7793_REFSEL_INT);
    AD7793_SetExcitDirection(AD7793_DIR_IEXC1_IOUT2_IEXC2_IOUT1);
    AD7793_SetExcitCurrent(AD7793_EN_IXCEN_210uA);
    AD7793_SetChannel(AD7793_CH_AIN3P_AIN3M);
    mess->Coderef = AD7793_ContinuousReadAvg(50);
    mess->Uref = ((mess->Coderef / 8388608) - 1) * 1.17; // code in voltage
}

in my main.c i call the function then:

referenzspannung(struct ADMESSUNG *mess);

Does anyone see a mistake? I think i did everything in the right order and i have the syntax from multiple websites. Thank you for the help!

1 Answer