I've noticed an annoying message during a build of C++ console application in Visual Studio 2019, Windows 10. I have a template function which produces a message:
message : see reference to function template instantiation 'int run_loop<wchar_t>(int,const char_type *[])' being compiled
with
[
char_type=wchar_t
]
Similar code compiles fine with no the message on macOS and Ubuntu, but now I'm porting it to Windwos and see this. It is not error or warning, just an info message. I started to comment out code blocks inside of the funtion and found that when I commented out std::exception
catching the message disappeared. What does this message mean and how should I deal with it? Leave it as is or should I redisign my code in some another way? Here is the simplified code snippet that produces the above message:
#include <exception>
template<class char_type>
int run_loop(int argc, const char_type* argv[])
{
try
{
}
catch (const std::exception& ex)
{
}
return 0;
}
int wmain(int argc, const wchar_t* argv[])
{
return run_loop(argc, argv);
}
My environment:
OS: Windows 10 Pro x64 Version 1909 OS build 18363.836
IDE: Visual Studio 2019 version 16.6.0
Win32 Console application template in C++ with default settings:
Windows SDK Version: 10.0
Platform Toolset: Visual Studio 2019 (v142)
This compiler messages does not stand for its own, it accompanies another message. Given your code the complete output is
warning C4100: 'argv': unreferenced formal parameter
message : see reference to function template instantiation 'int run_loop(int,const char_type *[])' being compiled
with
[
char_type=wchar_t
]
So the main message is the warning that argv
is an unreferenced formal parameter. The compilers gives you an additional hint with the message how the template was instantiated. That can be useful if you have multiple instantiations of a template and the warning only occurs with some instantiations.
BTW, after fixing that warning you still get the same message because argc
and ex
are also unused. After removing all three names or using them you don't get the warning and the message any more.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With