Error: unknown type name 'UBaseType_t'

I added a function definition to FreeRTOSconfig.h:

extern UBaseType_t xUnusedISRstackWords( void );  // check unused amount at runtime

I got, only in some ST FSL code (most modules don’t get this error), the following errors, which seem impossible:

C:\git_CAP\repo_MFW2\MFW2\application/FreeRTOSConfig.h:173:9: error: unknown type name 'UBaseType_t'
In file included from C:\git_CAP\repo_MFW2\MFW2\amazon-freertos\freertos_kernel\include/FreeRTOS.h:56,
             from C:\git_CAP\repo_MFW2\MFW2\component\osa/fsl_os_abstraction_free_rtos.h:63,
             from C:\git_CAP\repo_MFW2\MFW2\component\osa/fsl_os_abstraction.h:349,
             from C:\git_CAP\repo_MFW2\MFW2\usb\include/usb.h:15,
             from ../usb/device/source/lpcip3511/usb_device_lpcip3511.c:10:

Any idea how this is possible?
portmacro.h should always be included in FreeRTOS.h prior FreeRTOSconfig.h, no?

Thanks as always for any help,
Best Regards, Dave

Yes. In a C file that uses the FreeRTOS API or FreeRTOS types (as your prototype does) you should include FreeRTOS.h at the top of the file - neither portmacro.h or FreeRTOSConfig.h should be included explicitly because of some dependencies on the order of definitions - where by some definitions get defaulted if undefined elseswhere.

Does usb_device_lpcip3511.c include FreeRTOS.h though? I doubt it if it is an ST file.

Commenting on my own comment :slight_smile: Maybe it does include FreeRTOS.h otherwise FreeRTOSConfig.h would be included in the first place.

Thanks Richard, I see portmacro.h is included after FreeRTOSconfig.h in FreeRTOS.h, sorry. I’m trying to find a minimally-invasive way/place to add a definition for a FreeRTOS extension (in port.c mod). But in the error messages I showed, FreeRTOSconfig.h is included from FreeRTOS.h. No idea how I can get this error only in some modules using FreeRTOS.h - I’d expect the error everywhere - aaarrggg. Maybe I’ll give up and not use the typedef though that’s a bit ugly.
Thanks again,
Best Regards, Dave

For extensions added via the file included in task.c, I just add a new header file, something like mytask.h that defines those prototypes (and is also include in my extension file to verify the prototypes.