Husk
Husk

Reputation: 11

Return value type does not match the function type despite it working in many other points in the header

As the title reads. I have many other functions using the included method function, just doesn't seem to like this one.

Any help is appreciated.

Also excuse my probably incorrect terminology. I'm terrible with it.

Error 1 Error 2

Error

unsigned long Create_Font() noexcept
{
    using Create_Font = void(__thiscall*)(void*);
    return method<Create_Font>(66, this)(this);
}

Method Function

template<typename out,class type>
inline out method(size_t index, type* self) noexcept
{
    return reinterpret_cast<out>((*reinterpret_cast<void***>(self))[index]);
}

Upvotes: 1

Views: 129

Answers (1)

Turtlefight
Turtlefight

Reputation: 10680

Your Create_Font type is declared as returning void:

using Create_Font = void(__thiscall*)(void*);
//                    ^-- returns void

But your Create_Font function is defined as returning unsigned long:

unsigned long Create_Font() noexcept {
// ^-- returns unsigned long

    /* ... */
}

So your compiler will complain on return method<Create_Font>(66, this)(this);, because the result of method<Create_Font>(66, this)(this) is void, but the function needs to return an unsigned long.
(and there's no sensible way to "convert" void into unsigned long)

Upvotes: 1

Related Questions