Page 1 of 1

DS18B20 in argument

Posted: 01 Oct 2017 00:10
by coco82
Hi,

I try to make a function with the class DS18B20 in argument:

Code: Select all

void lectureTemp(DS18B20Sensor * capteur,  float* temp, int ligne)
When I compile, I get this error:

Code: Select all

C:\Users\Jerome\AppData\Local\Temp\build8533003694867026979.tmp\_Test_ucxx.c:673: error 98: conflict with previous definition of 'lectureTemp' for attribute 'type'
from type 'void function ( struct DS18B20Sensor generic* fixed, float generic* fixed, int fixed) __reentrant fixed'
  to type 'void function ( struct DS18B20Sensor generic* fixed, float generic* fixed, int fixed) __reentrant fixed'
Error. SDCC returned: 1
I don't understand where is the difference...

When I take a look in the file "prog_ucxx.c" , I find my function written like that:

Code: Select all

void lectureTemp(struct DS18B20Sensor * capteur, float * temp, int ligne);
Should it be written in this way ?

Code: Select all

void lectureTemp(struct cxx__class__DS18B20Sensor* capteur, float * temp, int ligne);

Re: DS18B20 in argument

Posted: 01 Oct 2017 00:25
by petergebruers
All I can tell you is that the uCxx is a simplified version of C++ and it does not support everything standard C++ does. As you have found out, uCxx translates your code to plain C (that is translated to assembly language and in the end linked into binary code) so that is why you suddenly see a struct... As a workaround, can you define that sensor as a global variable (like in the example on the forum)?