Expected primary-expression before 'const' with FreeRTOS

Hi, I'm having this error message when I follow the FreeRTOS tutorial. I've been looking online, but found nothing.

#include <Arduino_FreeRTOS.h>
void TaskBlink(void *pvParameters);
void TaskAnalogRead(void *pvParameters);

void setup() {
  // put your setup code here, to run once:
  xTaskCreate(TaskBlink, (const portCHAR*)"Blink", 128, NULL, 2, NULL);
}

void loop() {
  // put your main code here, to run repeatedly:
}

The error message is

   xTaskCreate(TaskBlink, (const portCHAR*)"Blink", 128, NULL, 2, NULL);
                                 ^~~~~~~~
sketch_nov17a:7:27: error: expected primary-expression before 'const'
   xTaskCreate(TaskBlink, (const portCHAR*)"Blink", 128, NULL, 2, NULL);
                           ^~~~~
sketch_nov17a:7:27: error: expected ')' before 'const'
exit status 1
expected primary-expression before 'const'

Hi @alpereira7

Try just removing the (const portCHAR)* and leaving just the string:

xTaskCreate(TaskBlink, "Blink", 128, NULL, 2, NULL);
1 Like

what’s that?

Now the error is

undefined reference to `TaskBlink(void*)'
collect2.exe: error: ld returned 1 exit status
exit status 1
Erreur de compilation pour la carte Arduino Uno

@killzone_kid I think it's a typedef from FreeRTOS... I need to check that maybe.

In your code you create a task called TaskBlink, where is TaskBlink in the code you posted?

If in setup you create a task:

xTaskCreatePinnedToCore( fFindDewPointWithHumidity,   "fFindDewPointWithHumidity", 23000, NULL, 3, NULL, 1 );

Then the task needs to be defined:

void fFindDewPointWithHumidity( void *pvParameters )
{
  TickType_t xLastWakeTime = xTaskGetTickCount();
  const TickType_t xFrequency = 1000;
  for ( ;; )
  {
    float temperature = oTemperature;
    float humi = oHumidity;
    //Celcius
    float ans =  (temperature - (14.55 + 0.114 * temperature) * (1 - (0.01 * humi)) - pow(((2.5 + 0.007 * temperature) * (1 - (0.01 * humi))),3) - (15.9 + 0.117 * temperature) * pow((1 - (0.01 * humi)), 14));
    log_i( "%f", ans );
    xLastWakeTime = xTaskGetTickCount();
    vTaskDelayUntil( &xLastWakeTime, xFrequency );
  }
  vTaskDelete( NULL );
}

That does not define the task.

1 Like

Of course! Sorry for that.

Your post was MOVED to its current location as it is more suitable.