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

rwel59
Posts: 97
Joined: Thu Oct 12, 2017 3:32 pm

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

Postby rwel59 » Sat Apr 21, 2018 6:14 pm

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*'

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

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

Postby kolban » Sun Apr 22, 2018 3:13 am

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.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

rwel59
Posts: 97
Joined: Thu Oct 12, 2017 3:32 pm

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

Postby rwel59 » Sun Apr 22, 2018 2:00 pm

thanks Neil, that solved it

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

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

Postby ESP_Angus » Mon Apr 23, 2018 12:59 am

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

rwel59
Posts: 97
Joined: Thu Oct 12, 2017 3:32 pm

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

Postby rwel59 » Tue Apr 24, 2018 12:32 am

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.

Who is online

Users browsing this forum: Vilius and 106 guests