Prefix of size_t variables

In the FreeRTOS doging guide, I read that:

  • Unsigned variables of non stdint types have an additional prefix u. For example, variables of type UBaseType_t (unsigned BaseType_t) are prefixed ux.

  • Variables of type size_t are also prefixed x.

Isn’t that a typo, the prefix x, shouldn’t that be ux?

size_t is an unsigned type, so shouldn’t it be:

size_t uxIndex;

I am asking this because of PR #1065, in which we had doubt about the correct name. I vote for the ux prefix.

This would be correct but very confusing:

    size_t xIndex;
    if( xIndex < 12U )

FreeRTOS uses an x, whereas the FreeRTOS libraries use an ux for variables of type size_t.

I agree with you that size_t should be prefixed ux since you are right, it is an unsigned non stdint type. I will ask the internal team just to make sure.


Jason Carroll

Hello Hein!

Apologies for the late reply.

Thank you for raising that question. We discussed internally and reached a conclusion that using ux is apt for size_t.

The coding guidelines do mention that we should use x but that was because size_t is non-standard type from FreeRTOS’s perspective. We might modify that after some discussions.

We haven’t yet decided on whether to update the kernel code to use ux instead of x as there might be some backward compatibility issues.

Going forward, we think that using ux is better when size_t is concerned.

Let me know if that helps.


1 Like