Cannot build kernel 10.5.1 without code change

Hi,

I am using FreeRTOS with C++. My kernel version is 10.5.1. In projdefs.h there is a pdMS_TO_TICKS macro which uses TickType_t type. Compiler(MSVC) cannot find the definition of TickType_t, because of that I have to add #include “portmacro.h” at the beginning of this file. Is it normal? What should I do to avoid Kernel code change?

Have a good day.

Could you show what FreeRTOS-related header files are included in your C++ file?

portmacro.h is included by portable.h, which is included by FreeRTOS.h. No need to include it directly.

In most project files you will include FreeRTOS.h, and possibly any of the other main header files like semphr.h, event_groups.h, task.h, or timers.h.

I am using FreeRTOS with C++

All header files produce C-linking :

#ifdef __cplusplus
    extern "C" {
#endif

/* Declarations. */

#ifdef __cplusplus
    } /* extern "C" */
#endif

so C++ files can also call FreeRTOS functions with the correct linkage.

NOTE: I just compiled/linked a complex C++ project with the 10.5.1 kernel, and it did not show and error or warning.

As Hein mentioned, if you are directly including projdefs.h, do not do that and include FreeRTOS.h instead.

One of my files was including projdefs.h. I changed it with FreeRTOS.h and problem is resolved.

Thank you for your quick and accurate answers.