C++ Visual studio 2012 error C3861: '_T': identifier not found? - visual-studio-2012

I have installed visual studio 2012 on 64 bit windows 7, and trying to build MFC Project, but on first debug always appear error:
Error 1 error C3861: '_T': identifier not found c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atlexcept.h 66
Error 3 error C3861: '_T': identifier not found c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atlcomcli.h 556
Error 4 error C3861: '_T': identifier not found c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atlcomcli.h 589
...
Where those _T macro have to be define? Why those problem appear?

#include <tchar.h> should work. If it is not.. Then try to do this ;
#ifdef _UNICODE
#define _T(x) L ## x
#else /* _UNICODE */
#define _T(x) x
#endif /* _UNICODE */

Related

I have no erors in my scripts I but receive many errors in the xlocnum, io, and the xiosbase files, I tried looking at the errors but dont understand

The errors might be showing because of the internal thing I had created and defined as static
here is the build ouput
1>------ Build started: Project: C++_Game_Stuff, Configuration: Debug Win32 ------
1>win64_maybe32_idk_platform.cpp
1>C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\xiosbase(41,1): error C2159:
more than one storage class specified
1>C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\xiosbase(93): message : see
reference to class template instantiation 'std::_Iosb<_Dummy>' being compiled
1>C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\xiosbase(41,43): error C2059:
syntax error: '='
1>C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\xiosbase(41,1): error C2238:
unexpected token(s) preceding ';'
1>C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\xiosbase(112,56): error C2589:
'static': illegal token on right side of '::'
1>C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\xiosbase(112,1): error C2062:
type 'unknown-type' unexpected
1>C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\xlocnum(1439,73): error C2589:
'static': illegal token on right side of '::'
1>C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\xlocnum(1555): message : see
reference to class template instantiation 'std::num_put<_Elem,_OutIt>' being compiled
1>C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\xlocnum(1522,73): error C2589:
'static': illegal token on right side of '::'
1>C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\ios(216,45): error C2059: syntax
error: 'type'
1>C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\ios(216,66): error C2143: syntax
error: missing ';' before '{'
1>C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\ios(216,66): error C2447: '{':
missing function header (old-style formal list?)
1>C:\Users\maazs\source\repos\C++_Game_Stuff\C++_Game_Stuff\win64_maybe32_idk_platform.cpp(71,5): warning C4007: 'WinMain': must be '__stdcall'
1>Done building project "C++_Game_Stuff.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The rest of the code is just warnings about int to float conversions:
I am not to skilled in programming and I am also following a tutorial however though I believe I had defined a macro variable for the static keyword called #define internal static however this had caused errors due to the files I was talking about(Xiobase, xlocnum, io) containing a keyword named internal thus causing errors because of the two variables with different meaning having the same name the program was confused.

msbuild-bin/cl.exe doesn't know what std::apply is?

I was playing with VS2019 and found out that it works with clang. So I installed clang and I've been having some issues with it working with VS2019. However, this issue is only based on the compiler. Seems that if I were to compile with the command line:
C:\Program Files\LLVM\msbuild-bin\cl.exe /std:c++17 source.cpp
Where source.cpp contains:
#include <tuple>
#include <iostream>
void fn(int x)
{
std::cout << x << std::endl;
}
int main()
{
std::tuple<int> x(1);
apply(fn, x);
return 0;
}
It barfs up:
clang-cl.exe: warning: argument unused during compilation: '/std:c++17' [-Wunused-command-line-argument]
In file included from source.cpp:1:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.20.27508\include\tuple:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.20.27508\include\new:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.20.27508\include\exception:7:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.20.27508\include\yvals.h:7:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.20.27508\include\yvals_core.h(334,2): error: STL1000: Unexpected compiler version, expected Clang 7 or newer.
#error STL1000: Unexpected compiler version, expected Clang 7 or newer.
^
source.cpp(12,3): error: use of undeclared identifier 'apply'
apply(fn, x);
^
2 errors generated.
However, if I use:
"C:\Program Files\LLVM\bin\clang-cl" /std:c++17 source.cpp
All is well.
Thing is, VS2019 is using the former compiler executable. How do I get it to use the latter?
The only thing I did to change the builder was to go and change this item:
Is there anything else I am to be changing?

Compiler errors in standard C library headers in VS2015 - Visual C++ Console Application project

I recently created a VS2015 solution to continue development on a C++ project I had been working on. Whenever I try to build the project, I get hundreds of errors from standard C library header files such as string.h, stdio.h, etc.
To try to get to the root of the problem, I created a new, very basic, VC++ win32 console application project, wondering if I'd see the same compiler errors. Here is the code (ConsoleApplication1.cpp):
#include <string>
#include <iostream>
int main()
{
std::string s = "some data to print...";
std::cout << "Printing: " << s.c_str() << std::endl;
return 0;
}
When I attempt to compile this, I get 150+ errors, like this:
1>------ Build started: Project: ConsoleApplication1, Configuration: Release Win32 ------
1> stdafx.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(309): error C2144: syntax error: 'int' should be preceded by ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(309): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(311): error C2144: syntax error: 'int' should be preceded by ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(311): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(311): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(309): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(317): error C2144: syntax error: 'int' should be preceded by ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(317): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(317): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(309): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(320): error C2144: syntax error: 'int' should be preceded by ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(320): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(320): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdio.h(309): note: see declaration of '_CRTIMP_ALTERNATIVE'
....etc
I have tried to 'repair' Microsoft VC++ 2015 Redistributable(x86) via the Windows 'Uninstall or change a program' utility, to no avail. I also tried to repair Visual Studio 2015 as a whole.
I'm on Windows 7.
Anyone have an idea what is going on here? Am I pointed to the wrong include directory or something?
It appears you have (some of) the headers from a previous version of VS installed in your VS2015 folder. The standard headers in VS2015 are stored off in a folder tied to the version of the CRT (something like c:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt). Repairing or reinstalling VS2015 won't fix this.
I think you'll need to uninstall VS2015, completely delete the folder C:\Program Files (x86)\Microsoft Visual Studio 14.0, then reinstall it. This will likely break the other version (VS2013?) that is installed there, so you might want/need to uninstall that version instead, then repair VS2015.
The header that comes with VS2015 does not appear to have the "int _CRTIMP_ALTERNATIVE" listed in some of the error messages at those lines, while the one with VS2013 does.

VC++ CefSharp Import Win32 -> x64 error

In VS2013 Community Edition, I had a Win32 VC++ clr project I've been working on. I'm trying to use the CefSharp library, and so through nuget I've imported it.
Following the steps found here I learned I had to change from Win32 to x64 as my 'Active solution platform' to avoid this:
error : CefSharp.Common does not work correctly on 'Win32' platform. You need to specify platform (x86 / x64).
However when I follow those steps and add x64 to my project through the configuration manager, I get the following compilation errors:
1>------ Build started: Project: PROJECTNAME, Configuration: Release x64 ------
1> Main.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\system_error(20): error C2869: 'std::errc' : has already been defined to be a namespace
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\system_error(101): error C2146: syntax error : missing ';' before identifier 'generic_errno'
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\system_error(101): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\system_error(101): fatal error C1903: unable to recover from previous error(s); stopping compilation
I'm not sure what is causing this or how to solve it.

VC++: Code works in VS2010 and breaks in VS2013

Edit: unlike the case in the question noted in the vote-to-close, the offending code here is CRT code, not mine. Even if it has a problem (which I'm pretty sure it doesn't), I have no way of fixing its source.
We have some legacy memory-leak tracing code that uses some CRT internals (nothing too exotic, essentially _CrtMemBlockHeader which is sort-of documented). While trying to migrate from VS2010 to VS2013 the code seems to cause sporadic build failures, and the offending part can be reduced to this:
#include <windows.h>
#define _CRTBLD
#include <..\crt\src\dbgint.h>
#include <fstream>
void Func()
{
std::ofstream myfile;
myfile << 8;
}
I.e., these 10 lines alone builds fine in VS2010 and in VS2013 give:
c:\program files (x86)\microsoft visual studio
12.0\vc\include\xlocnum(1105): error C2491: 'std::numpunct<_Elem>::id' : definition of dllimport static data member not allowed
I suspect the error message is not accurate - there are indeed several potential definitions of id, none of them at line 1105. There is also a considerable spew of warnings:
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\xlocnum(1105): warning C4273: 'id' : inconsistent dll linkage
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\xlocnum(80) : see previous definition of 'public: static std::locale::id std::numpunct<char>::id'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\xlocnum(80) : while compiling class template static data member 'std::locale::id std::numpunct<_Elem>::id'
1> with
1> [
1> _Elem=char
1> ]
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\xlocnum(1185) : see reference to function template instantiation 'const _Facet &std::use_facet<std::numpunct<_Elem>>(const std::locale &)' being compiled
1> with
1> [
1> _Facet=std::numpunct<char>
1> , _Elem=char
1> ]
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\xlocnum(1179) : while compiling class template member function 'std::ostreambuf_iterator<char,std::char_traits<char>> std::num_put<char,std::ostreambuf_iterator<char,std::char_traits<char>>>::do_put(_OutIt,std::ios_base &,_Elem,std::_Bool) const'
1> with
1> [
1> _OutIt=std::ostreambuf_iterator<char,std::char_traits<char>>
1> , _Elem=char
1> ]
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(306) : see reference to class template instantiation 'std::num_put<char,std::ostreambuf_iterator<char,std::char_traits<char>>>' being compiled
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\ostream(292) : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(int)'
1> c:\users\ofek\documents\visual studio 2013\projects\testcamsys2013\testcamsys2013\source.cpp(10) : see reference to function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(int)' being compiled
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\fstream(921) : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being compiled
1> c:\users\ofek\documents\visual studio 2013\projects\testcamsys2013\testcamsys2013\source.cpp(9) : see reference to class template instantiation 'std::basic_ofstream<char,std::char_traits<char>>' being compiled
For now I'm pasting the definitions of _CrtMemBlockHeader and some macros around it directly to my code. But still - can anyone see what broke?
I realize it is not fully supported, but one can hope: is there a more robust way of using _CrtMemBlockHeader?
Looking at this error on my system, it seems to be only related to the #define _CRTBLD and the fstream header. The included dbgint.h is irrelevant (you can comment out that #include and still get the same error.
So, this seems to be a problem in the fstream header. Changing the order of inclusion removes the compilation errors:
#include <windows.h>
#include <fstream>
#define _CRTBLD
#include <..\crt\src\dbgint.h>
Perhaps this helps?

Resources