How to resolve the warning message "LNK4248: unresolved typeref token (01000017) for 'tskTaskControlBlock'; image may not run"?

I have a project which uses an external library as a reference. The external library on the other hand, uses the FreeRTOS library. But when comes for building the project I get this warning (assuming ExternalHeader.obj is the current obj file being created and the ExternalHeader.hpp is a header from the external library my project uses):

ExternalHeader.obj : warning LNK4248: unresolved typeref token (01000017) for ‘tskTaskControlBlock’; image may not run

This tskTaskControlBlock structure has a declaration in the FreeRTOS’s task.h file:

struct tskTaskControlBlock; /* The old naming convention is used to prevent breaking kernel aware debuggers. */
typedef struct tskTaskControlBlock* TaskHandle_t;

Then the task.h header is included in the external’s ExternalHeader.hpp header:

#include <FreeRTOS.h>
#include <task.h>

// multiple functions declarations which use TaskHandle_t pointers either as parameters or for return types.

My project needs to use some of the functions from ExternalHeader.hpp so it has the ExternalHeader.cpp file with actual functions implementations:

#include <ExternalHeader.hpp>
// functions definitions of ones not-defined in ExternalHeader.hpp

And finally, I defined the tskTaskControlBlock struct in one of the cpp files in my project on the place where I need to use TaskHandle_t :

struct tskTaskControlBlock {
  uint32_t ulNotifiedValue = 0;
  uint8_t ucNotifyState = 0;
} dummyTCB;

TaskHandle_t NotificationTaskDummy = &dummyTCB;
// Use further NotificationTaskDummy 

So this is what I tried to resolve the warning but so far with no success:

  • move the tskTaskControlBlock definition to a header file in my project - the warning still appears as before;
  • Removed the definition of mine of tskTaskControlBlock from the file in my project - the warning still appears;
  • change the name of “ExternalHeader.cpp” from my project to “ExternalHeader2.cpp” - the warning message changed to “ExternalHeader2.obj : warning LNK4248…”;
  • added the definition of tskTaskControlBlock in the FreeRTOS task.h - this way the warning DID disappear! But changing task.h is no use for me as it is version specific from the external library and it will change dynamically.

Any suggestions how to get rid of this warning?

The IDE I use is Visual Studio 2019, FreeRTOS kernel V10.5.1, if that’s matter…

It is an opaque pointer which is defined in the kernel here. You are not supposed to define this struct.

This page provides more details about this warning - Linker Tools Warning LNK4248 | Microsoft Learn.

Since FreeRTOS APIs operate on opaque pointers, you can safely ignore and suppress this warning. Let us know if you face any problem.

Thanks for your fast reply and guidance! OK, I will suppress the warning.