Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error C3861: 'GenericWriteVariableUnsigned': identifier not found #1115

Closed
jeanga opened this issue Jul 26, 2021 · 1 comment · Fixed by #1118
Closed

error C3861: 'GenericWriteVariableUnsigned': identifier not found #1115

jeanga opened this issue Jul 26, 2021 · 1 comment · Fixed by #1118

Comments

@jeanga
Copy link

jeanga commented Jul 26, 2021

When I naively compile using bond, I always get the following error message:

7>S:\vcpkg\installed\x64-windows-static\include\bond\protocol\encoding.h(53,5): error C3861: 'GenericWriteVariableUnsigned': identifier not found (compiling source file F:\Projects\Flashback\tests\FlashTest\bond_dictionary.cpp)
7>S:\vcpkg\installed\x64-windows-static\include\bond\protocol\encoding.h(53,5): message : 'GenericWriteVariableUnsigned': function was not declared in the template definition context and can be found only via argument-dependent lookup in the instantiation context (compiling source file F:\Projects\Flashback\tests\FlashTest\bond_dictionary.cpp)
7>S:\vcpkg\installed\x64-windows-static\include\bond\protocol\compact_binary.h(814): message : see reference to function template instantiation 'void bond::WriteVariableUnsigned<Flashback::Details::Bond::Stream,T>(Buffer &,T)' being compiled
7>        with
7>        [
7>            T=uint32_t,
7>            Buffer=Flashback::Details::Bond::Stream
7>        ] (compiling source file F:\Projects\Flashback\tests\FlashTest\bond_dictionary.cpp)
7>S:\vcpkg\installed\x64-windows-static\include\bond\protocol\compact_binary.h(892): message : see reference to function template instantiation 'void bond::CompactBinaryWriter<Flashback::Details::Bond::Stream>::Write<uint32_t>(const T &)' being compiled
7>        with
7>        [
7>            T=uint32_t
7>        ] (compiling source file F:\Projects\Flashback\tests\FlashTest\bond_dictionary.cpp)
7>S:\vcpkg\installed\x64-windows-static\include\bond\protocol\compact_binary.h(892): message : see reference to function template instantiation 'void bond::CompactBinaryWriter<Flashback::Details::Bond::Stream>::Write<uint32_t>(const T &)' being compiled
7>        with
7>        [
7>            T=uint32_t
7>        ] (compiling source file F:\Projects\Flashback\tests\FlashTest\bond_dictionary.cpp)
7>S:\vcpkg\installed\x64-windows-static\include\bond\protocol\compact_binary.h(717): message : see reference to function template instantiation 'void bond::CompactBinaryWriter<Flashback::Details::Bond::Stream>::LengthBegin<Flashback::Details::Bond::Stream>(T &)' being compiled
7>        with
7>        [
7>            T=Flashback::Details::Bond::Stream
7>        ] (compiling source file F:\Projects\Flashback\tests\FlashTest\bond_dictionary.cpp)
7>S:\vcpkg\installed\x64-windows-static\include\bond\protocol\compact_binary.h(717): message : see reference to function template instantiation 'void bond::CompactBinaryWriter<Flashback::Details::Bond::Stream>::LengthBegin<Flashback::Details::Bond::Stream>(T &)' being compiled
7>        with
7>        [
7>            T=Flashback::Details::Bond::Stream
7>        ] (compiling source file F:\Projects\Flashback\tests\FlashTest\bond_dictionary.cpp)
7>S:\vcpkg\installed\x64-windows-static\include\bond\protocol\compact_binary.h(714): message : while compiling class template member function 'void bond::CompactBinaryWriter<Flashback::Details::Bond::Stream>::WriteStructBegin(const bond::Metadata &,bool)' (compiling source file F:\Projects\Flashback\tests\FlashTest\bond_dictionary.cpp)
7>S:\vcpkg\installed\x64-windows-static\include\bond\core\transforms.h(73): message : see reference to function template instantiation 'void bond::CompactBinaryWriter<Flashback::Details::Bond::Stream>::WriteStructBegin(const bond::Metadata &,bool)' being compiled (compiling source file F:\Projects\Flashback\tests\FlashTest\bond_dictionary.cpp)
7>F:\Projects\Flashback\tests\FlashTest\bond_dictionary.cpp(153): message : see reference to class template instantiation 'bond::CompactBinaryWriter<Flashback::Details::Bond::Stream>' being compiled

This seems to be because GenericWriteVariableUnsigned appears used before it is defined (encoding.h, line 45):

template<typename Buffer, typename T>
inline
typename boost::disable_if<implements_varint_write<Buffer, T> >::type
WriteVariableUnsigned(Buffer& output, T value)
{
    BOOST_STATIC_ASSERT(std::is_unsigned<T>::value);

    // Use generic WriteVariableUnsigned
    GenericWriteVariableUnsigned(output, value);
}


template<typename Buffer, typename T>
BOND_NO_INLINE
void GenericWriteVariableUnsigned(Buffer& output, T value)
{
....
}

I always 'fix' this compile error with a forward declaration of GenericWriteVariableUnsigned:

template<typename Buffer, typename T>
BOND_NO_INLINE
void GenericWriteVariableUnsigned(Buffer& output, T value);

template<typename Buffer, typename T>
inline
typename boost::disable_if<implements_varint_write<Buffer, T> >::type
WriteVariableUnsigned(Buffer& output, T value)
{
...
}

Please let me know if this is an issue from my side or if this 'fix' should be included in future releases of bond.

Best,
Jean

chwarr added a commit to chwarr/bond that referenced this issue Sep 3, 2021
Some users are reporting that they are receiving error "C3861:
'GenericWriteVariableUnsigned': identifier not found" when building.

I think this happens when custom streams that _do not_ have their own
`WriteVariableUnsigned` member function.

Add a forward declaration of `GenericWriteVariableUnsigned`.

Fixes microsoft#1115
@chwarr
Copy link
Member

chwarr commented Sep 3, 2021

Yes, a forward declaration makes sense. I've created PR #1118 [c++] Forward declare GenericWriteVariableUnsigned. Take a look if you have a moment, please.

My hypothesis for why you are seeing this is that your Flashback::Details::Bond::Stream does not have a WriteVariableUnsigned(T value) member function. Is that the case? (A Bond stream doesn't need to have such a member function, but if one exists, it will be used over GenericWriteVariableUnsigned.)

If you add a definition of WriteVariableUnsigned(T value) to your Flashback::Details::Bond::Stream does this error go away?

My guess is that we're not seeing this in Bond itself because bond::OutputBuffer has such a member function, so the WriteVariableUnsigned specialization that invokes GenericWriteVariableUnsigned is not used.

@chwarr chwarr added the bug label Sep 3, 2021
chwarr added a commit that referenced this issue Sep 7, 2021
Some users are reporting that they are receiving error "C3861:
'GenericWriteVariableUnsigned': identifier not found" when building.

I think this happens when custom streams that _do not_ have their own
`WriteVariableUnsigned` member function.

Add a forward declaration of `GenericWriteVariableUnsigned`.

Fixes #1115
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants