AI-Toolbox icon indicating copy to clipboard operation
AI-Toolbox copied to clipboard

error C3779: 'AIToolbox::IndexMapIterator<IdsIterator,Container>::operator *': a function that returns 'auto' cannot be used before it is defined

Open jianchenghao opened this issue 3 years ago • 11 comments

When the .sln is built, there would be error C3779, e.g., 'AIToolbox::IndexMapIterator<IdsIterator,Container>::operator *': a function that returns 'auto' cannot be used before it is defined. Is there any method to solve it?

jianchenghao avatar Jul 23 '22 15:07 jianchenghao

This seems strange. Is there any more context to this error?

Svalorzen avatar Jul 23 '22 18:07 Svalorzen

Build started... 1>------ Build started: Project: ZERO_CHECK, Configuration: RelWithDebInfo x64 ------ 1>Checking Build System 2>------ Build started: Project: AIToolboxMDP, Configuration: RelWithDebInfo x64 ------ 3>------ Build started: Project: Global_ToolsTests, Configuration: RelWithDebInfo x64 ------ 4>------ Build started: Project: Global_UtilsAdamTests, Configuration: RelWithDebInfo x64 ------ 5>------ Build started: Project: Global_UtilsCoreTests, Configuration: RelWithDebInfo x64 ------ 6>------ Build started: Project: Global_UtilsIOTests, Configuration: RelWithDebInfo x64 ------ 7>------ Build started: Project: Global_UtilsProbabilityTests, Configuration: RelWithDebInfo x64 ------ 8>------ Build started: Project: Global_UtilsPruneTests, Configuration: RelWithDebInfo x64 ------ 2>Building Custom Rule D:/OneDrive - HKUST Connect/VS_Code/VStools/AI-Toolbox/src/CMakeLists.txt 3>Building Custom Rule D:/OneDrive - HKUST Connect/VS_Code/VStools/AI-Toolbox/test/CMakeLists.txt 4>Building Custom Rule D:/OneDrive - HKUST Connect/VS_Code/VStools/AI-Toolbox/test/CMakeLists.txt 6>Building Custom Rule D:/OneDrive - HKUST Connect/VS_Code/VStools/AI-Toolbox/test/CMakeLists.txt 5>Building Custom Rule D:/OneDrive - HKUST Connect/VS_Code/VStools/AI-Toolbox/test/CMakeLists.txt 7>Building Custom Rule D:/OneDrive - HKUST Connect/VS_Code/VStools/AI-Toolbox/test/CMakeLists.txt 2>Seeder.cpp 8>Building Custom Rule D:/OneDrive - HKUST Connect/VS_Code/VStools/AI-Toolbox/test/CMakeLists.txt 4>UtilsAdamTests.cpp 6>UtilsIOTests.cpp 7>UtilsProbabilityTests.cpp 8>UtilsPruneTests.cpp 3>ToolsTests.cpp 5>UtilsCoreTests.cpp 2>D:\OneDrive - HKUST Connect\VS_Code\VStools\eigen-3.4.0\Eigen\src/Core/arch/Default/Half.h(1,1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss 2>D:\OneDrive - HKUST Connect\VS_Code\VStools\eigen-3.4.0\Eigen\src/Core/arch/Default/BFloat16.h(1,1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss 2>D:\OneDrive - HKUST Connect\VS_Code\VStools\eigen-3.4.0\Eigen\src/Core/arch/Default/GenericPacketMathFunctions.h(676,1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss 4>D:\OneDrive - HKUST Connect\VS_Code\VStools\eigen-3.4.0\Eigen\src/Core/arch/Default/Half.h(1,1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss 8>D:\OneDrive - HKUST Connect\VS_Code\VStools\eigen-3.4.0\Eigen\src/Core/arch/Default/Half.h(1,1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss 7>D:\OneDrive - HKUST Connect\VS_Code\VStools\eigen-3.4.0\Eigen\src/Core/arch/Default/Half.h(1,1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss 4>D:\OneDrive - HKUST Connect\VS_Code\VStools\eigen-3.4.0\Eigen\src/Core/arch/Default/BFloat16.h(1,1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss 4>D:\OneDrive - HKUST Connect\VS_Code\VStools\eigen-3.4.0\Eigen\src/Core/arch/Default/GenericPacketMathFunctions.h(676,1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss 6>D:\OneDrive - HKUST Connect\VS_Code\VStools\eigen-3.4.0\Eigen\src/Core/arch/Default/Half.h(1,1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss 6>D:\OneDrive - HKUST Connect\VS_Code\VStools\eigen-3.4.0\Eigen\src/Core/arch/Default/BFloat16.h(1,1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss 7>D:\OneDrive - HKUST Connect\VS_Code\VStools\eigen-3.4.0\Eigen\src/Core/arch/Default/BFloat16.h(1,1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss 7>D:\OneDrive - HKUST Connect\VS_Code\VStools\eigen-3.4.0\Eigen\src/Core/arch/Default/GenericPacketMathFunctions.h(676,1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss 8>D:\OneDrive - HKUST Connect\VS_Code\VStools\eigen-3.4.0\Eigen\src/Core/arch/Default/BFloat16.h(1,1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss 8>D:\OneDrive - HKUST Connect\VS_Code\VStools\eigen-3.4.0\Eigen\src/Core/arch/Default/GenericPacketMathFunctions.h(676,1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss 6>D:\OneDrive - HKUST Connect\VS_Code\VStools\eigen-3.4.0\Eigen\src/Core/arch/Default/GenericPacketMathFunctions.h(676,1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss 6>D:\OneDrive - HKUST Connect\VS_Code\VStools\AI-Toolbox\test\UtilsIOTests.cpp(33,67): warning C4267: 'argument': conversion from 'size_t' to '_Ty', possible loss of data 6> with 6> [ 6> _Ty=unsigned int 6> ] 2>D:\OneDrive - HKUST Connect\VS_Code\VStools\AI-Toolbox\src\Seeder.cpp(10,78): warning C4244: '=': conversion from '_Rep' to 'unsigned int', possible loss of data 2> with 2> [ 2> _Rep=std::chrono::system_clock::rep 2> ] 6>D:\OneDrive - HKUST Connect\VS_Code\VStools\AI-Toolbox\test\UtilsIOTests.cpp(66,67): warning C4267: 'argument': conversion from 'size_t' to '_Ty', possible loss of data 6> with 6> [ 6> _Ty=unsigned int 6> ] 3>D:\OneDrive - HKUST Connect\VS_Code\VStools\eigen-3.4.0\Eigen\src/Core/arch/Default/Half.h(1,1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss 8>D:\OneDrive - HKUST Connect\VS_Code\VStools\AI-Toolbox\include\AIToolbox/Utils/IndexMap.hpp(45,52): error C3779: 'AIToolbox::IndexMapIterator<IdsIterator,Container>::operator *': a function that returns 'auto' cannot be used before it is defined 8>D:\OneDrive - HKUST Connect\VS_Code\VStools\AI-Toolbox\include\AIToolbox/Utils/IndexMap.hpp(43): message : see declaration of 'AIToolbox::IndexMapIterator<IdsIterator,Container>::operator *' 8>D:\OneDrive - HKUST Connect\VS_Code\VStools\AI-Toolbox\include\AIToolbox/Utils/IndexMap.hpp(148): message : see reference to class template instantiation 'AIToolbox::IndexMapIterator<IdsIterator,Container>' being compiled 8>D:\OneDrive - HKUST Connect\VS_Code\VStools\AI-Toolbox\include\AIToolbox/Utils/IndexMap.hpp(46,58): error C3779: 'AIToolbox::IndexMapIterator<IdsIterator,Container>::operator *': a function that returns 'auto' cannot be used before it is defined 8>D:\OneDrive - HKUST Connect\VS_Code\VStools\AI-Toolbox\include\AIToolbox/Utils/IndexMap.hpp(43): message : see declaration of 'AIToolbox::IndexMapIterator<IdsIterator,Container>::operator *' 8>D:\OneDrive - HKUST Connect\VS_Code\VStools\AI-Toolbox\include\AIToolbox/Utils/IndexMap.hpp(317,52): error C3779: 'AIToolbox::IndexSkipMapIterator<IdsContainer,Container>::operator *': a function that returns 'auto' cannot be used before it is defined 3>D:\OneDrive - HKUST Connect\VS_Code\VStools\eigen-3.4.0\Eigen\src/Core/arch/Default/BFloat16.h(1,1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss 3>D:\OneDrive - HKUST Connect\VS_Code\VStools\eigen-3.4.0\Eigen\src/Core/arch/Default/GenericPacketMathFunctions.h(676,1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss 7>D:\OneDrive - HKUST Connect\VS_Code\VStools\AI-Toolbox\include\AIToolbox/Utils/Probability.hpp(455,31): warning C4244: 'initializing': conversion from 'const double' to 'int', possible loss of data 7>D:\OneDrive - HKUST Connect\VS_Code\VStools\AI-Toolbox\test\UtilsProbabilityTests.cpp(57): message : see reference to function template instantiation 'size_t AIToolbox::VoseAliasSampler::sampleProbabilityAIToolbox::RandomEngine(G &) const' being compiled

jianchenghao avatar Jul 24 '22 04:07 jianchenghao

What compiler version are you using?

Svalorzen avatar Jul 24 '22 17:07 Svalorzen

It is Visual Studio 2019 (v142).

jianchenghao avatar Jul 25 '22 03:07 jianchenghao

Which version of 2019? I'm trying to reproduce the error but I haven't been able to yet. There's a high likelihood that the problem is from VS, and updating it to the latest version might resolve your issues.

Svalorzen avatar Jul 25 '22 09:07 Svalorzen

Ah, I think I was just able to. VS19.29 16.11 enabled C++20, and gives your error with the code: https://godbolt.org/z/o8x6d56sT

However, this disappears with the latest version of Visual Studio 19: https://godbolt.org/z/8KsE97dGP

Updating Visual Studio as much as possible is probably the only real way to fix this problem. VS was always a bit slow in fully supporting template features, so it's always good to keep it as up to date as possible.

Svalorzen avatar Jul 25 '22 09:07 Svalorzen

Thank you for your help. The version I used is Microsoft Visual Studio Community 2019 Version 16.11.17

jianchenghao avatar Jul 25 '22 09:07 jianchenghao

With the latest version of VS, there are still some errors. The first error occurs as below: 5>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(157,5): error MSB3073: The command "setlocal 5>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(157,5): error MSB3073: rsync -r "D:/OneDrive - HKUST Connect/VS_Code/VStools/AI-Toolbox/test/data" "D:/OneDrive - HKUST Connect/VS_Code/VStools/AI-Toolbox/build/test" 5>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(157,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd 5>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(157,5): error MSB3073: :cmEnd 5>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(157,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone 5>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(157,5): error MSB3073: :cmErrorLevel 5>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(157,5): error MSB3073: exit /b %1 5>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(157,5): error MSB3073: :cmDone 5>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(157,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd 5>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(157,5): error MSB3073: :VCEnd" exited with code 9009. 5>Done building project "Global_UtilsCoreTests.vcxproj" -- FAILED.

jianchenghao avatar Jul 25 '22 11:07 jianchenghao

Looks like this error? https://stackoverflow.com/questions/10504377/added-and-removed-file-in-visualstudio-compile-errors

Svalorzen avatar Jul 25 '22 11:07 Svalorzen

I run the code again in administrator privilege, however, the error is still there. Is it because I used the Windows system?

jianchenghao avatar Jul 25 '22 12:07 jianchenghao

To be honest I don't have much experience on Windows, so I can't really help you. Googling is more likely to help in finding a solution.

If you find out that the solution turns out to be something I have to change in the project, I'll gladly do so. Until then I can't really do much, sorry.

Svalorzen avatar Jul 25 '22 14:07 Svalorzen