开发者

uint8_t and unsigned char linking error

开发者 https://www.devze.com 2023-02-02 04:23 出处:网络
I\'m using template function: template<typename T> void func(const T& value) { obj->func(value);

I'm using template function:

template<typename T> void func(const T& value)
{
    obj->func(value);
}

where obj is object of class:

void my_object::func(int64_t value) { ... }
void my_object::func(uint64_t value) { ... }
void my_object::func(uint32_t value) { ... }
void my_object::func(uint16_t value) { ... }
void my_object::func(uint8_t value) { ... }

The problem is with uint8_t overload of my_object::func() override. Linker complains about unresolved external symbols to overloads, which should have unsigned char parameter.

Should I replace uint8_t overload with unsigned char overload?

Edit: Just now noticed, that linker complains about uint64_t and int64_t too.

I compile on Windows using MSVC++ 2008 Express.

Edit: Apologies, I declared my_object::func(uint8_t value开发者_开发百科) function (and other), but I didn't defined it.


This is the include file should #include to use the above mentioned types (C99 recommendations)

#include <stdint.h>


I'm guessing that uint8_t has been typedefed as unsigned char, hence why you're seeing that.


Try compiling with

template void my_object::func(int64_t value) { ... }
template void my_object::func(uint64_t value) { ... }
template void my_object::func(uint32_t value) { ... }
template void my_object::func(uint16_t value) { ... }
template void my_object::func(uint8_t value) { ... }

fixed my problem with a similar issues

0

精彩评论

暂无评论...
验证码 换一张
取 消