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 this task.h header is included in the external’s ExternalHeader.hpp header:
#include <FreeRTOS.h>
#include <task.h>
// multiple functions declarations which only use the TaskHandle_t pointer either for parameter type or for return type.
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 declarations
And finally I need define this problematic tskTaskControlBlock
struct in one of the cpp files of 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 what I tried to resolve the warning so far but with no success:
- move the
tskTaskControlBlock
definition to a header file in my project - change the name of “ExternalHeader.cpp” to “ExternalHeader2.cpp” – the error changed to “ExternalHeader2.obj : warning LNK4248…”
- create two new simple projects and one is a reference of the other and create a struct declaration in the reference and define this struct in the other project. And here the warning is not shown…
Any suggestions how to get rid of this warning? I want zero warnings in my project but so far no success with this one…
The IDE I use is Visual Studio 2019 if that’s matter.