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
tskTaskControlBlockdefinition to a header file in my project - the warning still appears as before; - Removed the definition of mine of
tskTaskControlBlockfrom 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
tskTaskControlBlockin 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…