# Cannot build kernel 10.5.1 without code change

**URL:** <https://forums.freertos.org/t/cannot-build-kernel-10-5-1-without-code-change/16346>\
**Category:** Kernel\
**Created:** [December 8, 2022, 7:05am UTC](https://forums.freertos.org/t/cannot-build-kernel-10-5-1-without-code-change/16346 "2022-12-08T07:05:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ozanagma](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/ozanagma/32/3136_2.png) [@ozanagma](https://forums.freertos.org/u/ozanagma)\
**Post date:** [December 8, 2022, 7:05am UTC](https://forums.freertos.org/t/cannot-build-kernel-10-5-1-without-code-change/16346/1 "2022-12-08T07:05:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![htibosch](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/htibosch/32/62_2.png) [@htibosch](https://forums.freertos.org/u/htibosch)\
**Post date:** [December 8, 2022, 7:24am UTC](https://forums.freertos.org/t/cannot-build-kernel-10-5-1-without-code-change/16346/2 "2022-12-08T07:24:41Z")

</div>

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 :

```auto
#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.

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [December 8, 2022, 9:11am UTC](https://forums.freertos.org/t/cannot-build-kernel-10-5-1-without-code-change/16346/3 "2022-12-08T09:11:44Z")

</div>

> [@ozanagma](#):
>
> 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.

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

---

<div class="post-metadata">

**Author:** ![ozanagma](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/ozanagma/32/3136_2.png) [@ozanagma](https://forums.freertos.org/u/ozanagma)\
**Post date:** [December 8, 2022, 12:18pm UTC](https://forums.freertos.org/t/cannot-build-kernel-10-5-1-without-code-change/16346/4 "2022-12-08T12:18:16Z")

</div>

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.
