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 C3779: 'AIToolbox::IndexMapIterator<IdsIterator,Container>::operator *': a function that returns 'auto' cannot be used before it is defined #62

Open
jianchenghao opened this issue Jul 23, 2022 · 11 comments

Comments

@jianchenghao
Copy link

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?

@Svalorzen
Copy link
Owner

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

@jianchenghao
Copy link
Author

jianchenghao commented Jul 24, 2022

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

@Svalorzen
Copy link
Owner

What compiler version are you using?

@jianchenghao
Copy link
Author

It is Visual Studio 2019 (v142).

@Svalorzen
Copy link
Owner

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
Copy link
Owner

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.

@jianchenghao
Copy link
Author

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

@jianchenghao
Copy link
Author

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.

@Svalorzen
Copy link
Owner

@jianchenghao
Copy link
Author

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

@Svalorzen
Copy link
Owner

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.

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

No branches or pull requests

2 participants