Compiler errors when freertos h files included in more than one c file

Hello everyone,

I have a very simple setup with a main c file that includes the header of a second c file where the tasks are defined (hid_tasks.c).

In the main.c file, the tasks are created and I have the following includes:

In the hid_tasks.c file, the tasks are defined and I have the following includes:

In the hid_tasks.h file, the tasks are simply declared.

The compiler is chucking out the following errors:

In file included from hid_tasks.c:20:0:
task.h:162:5: error: expected specifier-qualifier-list before ‘configRUN_TIME_COUNTER_TYPE’
task.h:1810:35: error: expected declaration specifiers or ‘…’ before ‘configRUN_TIME_COUNTER_TYPE’
task.h:1957:29: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘ulTaskGetIdleRunTimeCounter’
task.h:1958:29: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘ulTaskGetIdleRunTimePercent’

The errors seem to be pointing to the freeRTOS kernel task.c file.
If I remove the freeRTOS includes from the hid_tasks.c file the errors disappear but, I obviously get other errors because main.c can’t ‘see’ the hid_tasks.c file that cointains the tasks definition.

Has anyone encountered a similar issue?

I seems like a very basic issue to me but, after a few hours investigating, I can’t get my head around fixing it.

Any and all help is very much appreciated.

HI @LuisMF

Its seems like your compiler is not able to identify configRUN_TIME_COUNTER_TYPE resulting in the errors.
Can you please check if configRUN_TIME_COUNTER_TYPE is defined in FreeRTOS.h?

1 Like

Hi @moninom1

Thank you for your reply.

I’ve just gone through the FreeRTOS.h file a few times and I cannot see the definition of (or any reference to) configRUN_TIME_COUNTER_TYPE.

I have not modified this file, or any file related to the FreeRTOS kernel at all. I’m currently using v202212.01.

Looking forward to hearing your thoughts.


After checking the project settings, I saw that the FreeRTOS.h file was duplicated.
It was being included in the common include menu from the FreeRTOS folder and it was also present in the project folder itself.

After removing it from the project folder, all errors cleaned up.

Sorry for the trouble, I’ll definitely learn from this one.

Thanks once again for your help!

1 Like