Page 1 of 1

ERROR running ADC Example: invalid conversion from 'void*'

Posted: Sat Apr 21, 2018 6:14 pm
by rwel59
starting on some adc stuff and grabbed the example ( esp-idf/examples/peripherals/adc/main/adc1_example_main.c)
compiler errors out on this line: adc_chars = calloc(1, sizeof(esp_adc_cal_characteristics_t));

with the following error:
error: invalid conversion from 'void*' to 'esp_adc_cal_characteristics_t*'

Re: ERROR running ADC Example: invalid conversion from 'void*'

Posted: Sun Apr 22, 2018 3:13 am
by kolban
It looks like the line which reads:

Code: Select all

adc_chars = calloc(1, sizeof(esp_adc_cal_characteristics_t));
should likely be:

Code: Select all

adc_chars = (esp_adc_cal_characteristics_t *)calloc(1, sizeof(esp_adc_cal_characteristics_t));
edit your copy of the sample and see if that makes progress.

Re: ERROR running ADC Example: invalid conversion from 'void*'

Posted: Sun Apr 22, 2018 2:00 pm
by rwel59
thanks Neil, that solved it

Re: ERROR running ADC Example: invalid conversion from 'void*'

Posted: Mon Apr 23, 2018 12:59 am
by ESP_Angus
Hi rwel59,

Did you copy the code from a .c file into a .cpp file? C (by default) allows implicit casting from void * to another pointer type, but C++ does not allow this without an explicit cast like the one kolban suggested.

Angus

Re: ERROR running ADC Example: invalid conversion from 'void*'

Posted: Tue Apr 24, 2018 12:32 am
by rwel59
Angus,
that is exactly what I did. just started looking at using the ADC's and copied the code from the espidf example.

thanks, I will keep that in mind next time I cut & paste.