Visual Studio Community 2015 MFC empty project doesn't compile - c++

I just installed Visual Studio Community 2015 (version 14.0.24720.00) and tried to create an MFC dialog based project.
In the wizard I only selected "Dialog based", leaving all the other settings to default.
The project simply doesn't compile, which isn't exactly a promising starting point...
Am I overlooking something? Is the MFC template broken?
Below, the compile time errors I get (I cut away the long paths for the sake of legibility).
Thanks for your time.
program files (x86)\microsoft visual studio 14.01>------ Build started: Project: MFCApplication, Configuration: Debug Win32 ------
1> stdafx.cpp
1>c:\[...omissis...]\atlcore.h(639): error C2065: 'LOAD_LIBRARY_SEARCH_SYSTEM32': undeclared identifier
1>c:\[...omissis...]\uianimation.h(2621): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\[...omissis...]\afxanimationhelper.h(411): error C2065: 'UI_E_VALUE_NOT_SET': undeclared identifier
1>c:\[...omissis...]\afxanimationhelper.h(441): error C2065: 'UI_E_VALUE_NOT_SET': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2103): error C3646: 'm_pConfigs': unknown override specifier
1>c:\[...omissis...]\afxwin.h(2103): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\[...omissis...]\afxwin.h(2024): error C2065: 'GC_PAN_WITH_GUTTER': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2024): error C2065: 'GC_PAN_WITH_INERTIA': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2088): error C2065: 'GC_ALLGESTURES': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2030): error C2065: 'GID_ZOOM': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2030): error C2065: 'GC_ZOOM': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2036): error C2065: 'GID_ROTATE': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2036): error C2065: 'GC_ROTATE': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2042): error C2065: 'GID_TWOFINGERTAP': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2042): error C2065: 'GC_TWOFINGERTAP': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2056): error C2065: 'GID_PAN': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2056): error C2065: 'GC_PAN': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2062): error C2065: 'GID_PAN': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2062): error C2065: 'GC_PAN_WITH_SINGLE_FINGER_VERTICALLY': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2068): error C2065: 'GID_PAN': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2068): error C2065: 'GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2074): error C2065: 'GID_PAN': undeclared identifier
1>c:\[...omissis...]\afxw
in.h(2074): error C2065: 'GC_PAN_WITH_GUTTER': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2080): error C2065: 'GID_PAN': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2080): error C2065: 'GC_PAN_WITH_INERTIA': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2964): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\[...omissis...]\afxwin.h(2964): error C3646: 'GetCurrentGestureInfo': unknown override specifier
1>c:\[...omissis...]\afxwin.h(2964): error C2059: syntax error: ')'
1>c:\[...omissis...]\afxwin.h(2965): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>c:\[...omissis...]\afxwin.h(3020): error C2061: syntax error: identifier 'PTOUCHINPUT'
1>c:\[...omissis...]\afxwin.h(3030): error C2061: syntax error: identifier 'PTOUCHINPUT'
1>c:\[...omissis...]\afxwin.h(3043): error C3646: 'm_pCurrentGestureInfo': unknown override specifier
1>c:\[...omissis...]\afxwin.h(3043): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\[...omissis...]\afxwin.h(4141): error C2061: syntax error: identifier 'TBPFLAG'
1>c:\[...omissis...]\afxwin.h(5447): error C2143: syntax error: missing ';' before '*'
1>c:\[...omissis...]\afxwin.h(5447): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\[...omissis...]\afxwin.h(5447): error C2238: unexpected token(s) preceding ';'
1>c:\[...omissis...]\afxglobals.h(315): error C2143: syntax error: missing ';' before '*'
1>c:\[...omissis...]\afxglobals.h(315): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\[...omissis...]\afxglobals.h(315): error C2238: unexpected token(s) preceding ';'
1>c:\[...omissis...]\afxadv.h(244): error C2143: syntax error: missing ';' before '*'
1>c:\[...omissis...]\afxadv.h(244): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\[...omissis...]\afxadv.h(245): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>c:\[...omissis...]\afxadv.h(314): error C2061: syntax error: identifier 'KNOWNDESTCATEGORY'
1>c:\[...omissis...]\afxadv.h(390): error C2065: 'ICustomDestinationList': undeclared identifier
1>c:\[...omissis...]\afxadv.h(390): error C2923: 'ATL::CComPtr': 'ICustomDestinationList' is not a valid template type argument for parameter 'T'
1>c:\[...omissis...]\afxadv.h(273): error C2039: 'AbortList': is not a member of 'ATL::_NoAddRefReleaseOnCComPtr<T>'
1>c:\[...omissis...]\afxadv.h(428): error C2065: 'IApplicationDestinations': undeclared identifier
1>c:\[...omissis...]\afxadv.h(428): error C2923: 'ATL::CComPtr': 'IApplicationDestinations' is not a valid template type argument for parameter 'T'
1>c:\[...omissis...]\afxadv.h(430): warning C4624: 'CAppDestinations': destructor was implicitly defined as deleted
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Solved.
Visual studio 2015 inherited the Visual Studio 2009 settings.
Removing the include folder
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include
everything started to work normally

Had a similar problem bringing 2010 forward to 2015. Tracked the problem down to the targetver.h file. It was defining older versions of windows. Replaced all previous defines with the current default.
target.h
// delete everything here
#include <SDKDDKVer.h>
-- end of target.h

Maybe this can help you to fix your problem.
In Visual Studio 2015, C++ tooling is no longer installed by default. Instead, the C++ compiler, libraries, and project templates have been moved into an optional feature. Upon launching setup, you can choose a “Typical” or “Custom” install;
If you choose “Typical”, then you can’t use Visual Studio to develop in C++, because only managed languages and web development tools will be installed.
Setup Changes in Visual Studio 2015 Affecting C++ Developers

Related

Installing OpenCV in C++ Visual Studio: How can I fix these linker errors that occur although I followed the installation tutorial?

I have tried downloading the C++ OpenCV Library to Visual Studio 2019.
When trying to compile my code, I am getting these errors:
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(40,9): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(40,19): error C2059: syntax error: 'constant'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(42,1): error C2143: syntax error: missing ';' before '{'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(42,1): error C2447: '{': missing function header (old-style formal list?)
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(68,62): error C2039: 'has_parenthesis_operator': is not a member of 'cv::sfinae'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(39): message : see declaration of 'cv::sfinae'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(68,1): error C2065: 'has_parenthesis_operator': undeclared identifier
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(68,1): error C2977: 'std::enable_if': too many template arguments
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xtr1common(46): message : see declaration of 'std::enable_if'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(68,117): error C2955: 'std::enable_if': use of class template requires template argument list
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xtr1common(46): message : see declaration of 'std::enable_if'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(68,131): error C2988: unrecognizable template declaration/definition
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(68,131): error C2059: syntax error: '>'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(69,11): error C2988: unrecognizable template declaration/definition
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(69,11): error C2059: syntax error: 'public'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(69,1): error C2143: syntax error: missing ';' before '{'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(69,1): error C2447: '{': missing function header (old-style formal list?)
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(80,26): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(140): message : see reference to class template instantiation 'cv::Ptr<T>' being compiled
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(80,35): error C2059: syntax error: 'constant'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(80,26): error C2334: unexpected token(s) preceding ':'; skipping apparent function body
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(140,1): fatal error C1903: unable to recover from previous error(s); stopping compilation
I suspect it is a linker errors, so I went ahead and made sure I have included all the dependencies and libraries, and I have done as follows, I included the opencv libraries and the library directories and added the additional dependencies:
yet I am still getting the same errors. Does anyone know how I can get rid of them?
Thank you for your help!
Link to the images: https://imgur.com/a/M1UV7yL

ATL complains about not including Windows after VS2012 -> VS2017

I'm currently update our projects from VS2012 to VS2017. This has led one project to crash and moan in compilation about ATL.
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(450): error C2143: syntax error: missing ')' before '__stdcall'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(450): error C2143: syntax error: missing ';' before '__stdcall'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(450): error C2059: syntax error: '__stdcall'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(450): error C2059: syntax error: ')'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(451): error C2065: 'PFNMOVEFILETRANSACTED': undeclared identifier
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(451): error C2146: syntax error: missing ';' before identifier 'pfMoveFileTransacted'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(451): error C2065: 'pfMoveFileTransacted': undeclared identifier
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(451): error C2146: syntax error: missing ';' before identifier 'GetProcAddress'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(453): error C2065: 'pfMoveFileTransacted': undeclared identifier
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(455): error C2065: 'pfMoveFileTransacted': undeclared identifier
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(571): error C2143: syntax error: missing ')' before '__stdcall'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(571): error C2143: syntax error: missing ';' before '__stdcall'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(571): error C2059: syntax error: '__stdcall'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(571): error C2059: syntax error: ')'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(572): error C2065: 'PFNFINDFIRSTFILETRANSACTED': undeclared identifier
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(572): error C2146: syntax error: missing ';' before identifier 'pfFindFirstFileTransacted'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(572): error C2065: 'pfFindFirstFileTransacted': undeclared identifier
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(572): error C2146: syntax error: missing ';' before identifier 'GetProcAddress'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(574): error C2065: 'pfFindFirstFileTransacted': undeclared identifier
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(576): error C2065: 'pfFindFirstFileTransacted': undeclared identifier
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(576): error C2065: 'FindExInfoStandard': undeclared identifier
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(576): error C2065: 'FindExSearchNameMatch': undeclared identifier
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atlcom.h(175): error C2065: 'COINIT_MULTITHREADED': undeclared identifier
1>Done building project "MyProj.vcxproj" -- FAILED.
With error lines such as "undeclared identifier" refers to headers in the windows.h library.
When I include I include through a StdAfx.h which has;
#include <atlbase.h>
#include <atlcom.h>
Regardless where I put Windows.h, the error occurs. I find it likely that it is generated by _WIN32_WINNTstuff but all of that "should" work. Is it deprecated? I don't know... Anyone have any ideas?
In my case there were multiple project including each others stdafx.h headers. This caused the macros to fail/corrupt. Sorting that out and using correct values of WINVER and _WIN32_WINNT fixed it all.
Aside from Alexander's answer make sure that you do NOT define the following:
#define NOTEXTMETRIC

I'm trying to add an external library to a Source mod, and I'm having some trouble

I'm trying to add this Serial Communications library to the Source SDK code to try to integrate my own serial input into Steam games. I've got the example projects on the Serial library I downloaded working fine. I added the Serial project to the Source solution and gave the "Server (HL2)" project a dependency to it (I'm using Visual Studio 2013 Express). I then went to my .cpp file under the Server (HL2) project and simply added
#include "Serial.h"
#define STRICT
#include <tchar.h>
#include <stdio.h>
#include <string.h>
which are the headers defined in the example project that was working for me, and got a lot of errors when I went to compile. The errors are all along the lines of:
\serial.h(190): error C2065: 'CE_RXOVER' : undeclared identifier
\serial.h(191): error C2065: 'CE_RXPARITY' : undeclared identifier
\serial.h(193): error C2065: 'CE_TXFULL' : undeclared identifier
\serial.h(215): error C2061: syntax error : identifier 'LPCTSTR'
\serial.h(220): error C2146: syntax error : missing ';' before identifier 'Open'
\serial.h(220): error C2433: 'CSerial::LONG' : 'virtual' not permitted on data declarations
\serial.h(220): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
\serial.h(220): error C2061: syntax error : identifier 'LPCTSTR'
\serial.h(220): warning C4183: 'Open': missing return type; assumed to be a member function returning 'int'
\serial.h(223): error C2146: syntax error : missing ';' before identifier 'Close'
\serial.h(223): error C2433: 'CSerial::LONG' : 'virtual' not permitted on data declarations
\serial.h(223): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
\serial.h(223): warning C4183: 'Close': missing return type; assumed to be a member function returning 'int'
\serial.h(241): error C2146: syntax error : missing ';' before identifier 'Setup'
\serial.h(241): error C2433: 'CSerial::LONG' : 'virtual' not permitted on data declarations
\serial.h(241): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
\serial.h(244): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
\serial.h(244): warning C4183: 'Setup': missing return type; assumed to be a member function returning 'int'
\serial.h(250): error C2146: syntax error : missing ';' before identifier 'SetEventChar'
\serial.h(250): error C2433: 'CSerial::LONG' : 'virtual' not permitted on data declarations
They repeat and then...
\serial.h(361): error C2061: syntax error : identifier 'LPOVERLAPPED'
\serial.h(329): error C2065: 'm_lLastError' : undeclared identifier
\serial.h(345): error C2065: 'DCBlength' : undeclared identifier
\serial.h(345): error C2065: 'DCB' : undeclared identifier
\serial.h(345): error C2070: 'unknown-type': illegal sizeof operand
There's also a whole lot more "undeclared identifiers" where that came from. I feel like there's a very obvious solution somewhere, either the way I have the solution set up or the linker or something. But it finds the file, it's just not interpreting it correctly it seems. When I take out
#include "Serial.h"
It compiles fine, so it has something to do with the way I'm adding that new header file. Any help would be much appreciated.

How to use opencv header in visual studio windows app

I did my work in visual studio 2010 c++ console , but now i am trying to convert my work into windows app (making interface of it) in visual studio c++ . For that i have to add some header files which i have to add manually in windows form application, like
and it show me some error's in it like
DetectRegions.h(10): error C2146: syntax error : missing ';' before identifier 'filename'
DetectRegions.h(10): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
DetectRegions.h(10): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
DetectRegions.h(11): error C2061: syntax error : identifier 'string'
DetectRegions.h(14): error C2143: syntax error : missing ';' before '<'
DetectRegions.h(14): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
DetectRegions.h(14): error C2238: unexpected token(s) preceding ';'
DetectRegions.h(16): error C2143: syntax error : missing ';' before '<'
DetectRegions.h(16): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
DetectRegions.h(16): error C2238: unexpected token(s) preceding ';'
DetectRegions.h(17): error C2061: syntax error : identifier 'RotatedRect'
DetectRegions.h(18): error C2653: 'cv' : is not a class or namespace name
DetectRegions.h(18): error C2146: syntax error : missing ';' before identifier 'histeq'
DetectRegions.h(18): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
DetectRegions.h(18): error C2061: syntax error : identifier 'Mat'
DetectRegions.h(18): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
DetectRegions.h(18): warning C4183: 'histeq': missing return type; assumed to be a member function returning 'int'
Plate.h is same like DetectRegions.h
I add the other headers of opencv in Form1.h like
#include "opencv2/features2d/features2d.hpp"
#include <opencv/highgui.h>
#include "opencv2/opencv.hpp" .......
You're using std::string and std::vector in DetectRegions.h, but aren't including their headers
#include <string>
#include <vector>
Likewise, you need to include the cv headers there if you're using them there.

Compiling differences in Visual C++ and *nix environments

Is there a difference between compiling projects in *nix environments and MS Visual C++?
For example, there is a "stdafx.h" file in Visual C++.
The reason I'm asking is that I submitted a piece of code which compiled in g++, to refactormycode.com. Then after it got a refactoring, it seemed to include a "stdafx.h", so I figured I'll download Visual C++ 2008 Express but I can't seem to get it to build.
What I'm doing is creating a new project > Create a Win32 Console Application, and replacing the auto-generated .cpp with the refactored code. Am I doing something wrong here?
This is the compiler errors I'm getting:
------ Build started: Project: bfs, Configuration: Debug Win32 ------
Compiling...
bfs.cpp
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(3) : error C2871: 'std' : a namespace with this name does not exist
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(8) : error C2143: syntax error : missing ';' before '<'
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(8) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(8) : error C2238: unexpected token(s) preceding ';'
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(25) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(25) : error C2143: syntax error : missing ';' before '&'
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(26) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(28) : warning C4183: 'getEdges': missing return type; assumed to be a member function returning 'int'
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(32) : error C2059: syntax error : '<'
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(32) : error C2238: unexpected token(s) preceding ';'
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(12) : error C2758: 'Vertex::Edges' : must be initialized in constructor base/member initializer list
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(25) : see declaration of 'Vertex::Edges'
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(22) : error C2065: 'm_edges' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(22) : error C2228: left of '.push_back' must have class/struct/union
type is ''unknown-type''
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(27) : error C2065: 'm_edges' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(38) : error C2143: syntax error : missing ';' before '<'
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(38) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(38) : error C2039: 'iterator' : is not a member of '`global namespace''
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(38) : error C2238: unexpected token(s) preceding ';'
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(41) : error C2059: syntax error : '<'
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(41) : error C2238: unexpected token(s) preceding ';'
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(83) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(83) : error C2143: syntax error : missing ';' before '&'
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(84) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(86) : warning C4183: 'getVertices': missing return type; assumed to be a member function returning 'int'
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(89) : error C2146: syntax error : missing ';' before identifier 'm_vertices'
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(89) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(89) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(43) : error C2758: 'Graph::Vertices' : must be initialized in constructor base/member initializer list
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(83) : see declaration of 'Graph::Vertices'
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(55) : error C2065: 'm_vertices' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(55) : error C2228: left of '.insert' must have class/struct/union
type is ''unknown-type''
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(61) : error C2065: 'VertexIterator' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(61) : error C2146: syntax error : missing ';' before identifier 'iter'
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(61) : error C2065: 'iter' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(62) : error C2065: 'iter' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(62) : error C2065: 'm_vertices' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(62) : error C2228: left of '.begin' must have class/struct/union
type is ''unknown-type''
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(62) : error C2065: 'iter' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(62) : error C2065: 'm_vertices' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(62) : error C2228: left of '.end' must have class/struct/union
type is ''unknown-type''
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(62) : error C2065: 'iter' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(64) : error C2065: 'iter' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(64) : error C2227: left of '->getId' must point to class/struct/union/generic type
type is ''unknown-type''
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(65) : error C2065: 'iter' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(78) : error C2065: 'VertexIterator' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(78) : error C2146: syntax error : missing ';' before identifier 'iter'
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(78) : error C2065: 'iter' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(79) : error C2065: 'iter' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(79) : error C2065: 'm_vertices' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(79) : error C2228: left of '.begin' must have class/struct/union
type is ''unknown-type''
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(79) : error C2065: 'iter' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(79) : error C2065: 'm_vertices' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(79) : error C2228: left of '.end' must have class/struct/union
type is ''unknown-type''
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(79) : error C2065: 'iter' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(80) : error C2065: 'iter' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(80) : error C2541: 'delete' : cannot delete objects that are not pointers
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(85) : error C2065: 'm_vertices' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(119) : error C2143: syntax error : missing ';' before '<'
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(119) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(119) : error C2238: unexpected token(s) preceding ';'
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(106) : error C2065: 'UINT_MAX' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(138) : error C2065: 'queue' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(138) : error C2059: syntax error : 'const'
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(140) : error C2065: 'Attributes' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(142) : error C2065: 'q' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(142) : error C2228: left of '.push' must have class/struct/union
type is ''unknown-type''
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(143) : error C2065: 'q' : undeclared identifier
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(143) : error C2228: left of '.empty' must have class/struct/union
type is ''unknown-type''
c:\users\admin\documents\visual studio 2008\projects\alg\bfs\bfs\bfs.cpp(143) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Build log was saved at "file://c:\Users\Admin\Documents\Visual Studio 2008\Projects\alg\bfs\bfs\Debug\BuildLog.htm"
bfs - 66 error(s), 2 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Add the below headers in the refactored code,
#include <iostream>
#include <limits>
#include <map>
#include <list>
#include <queue>
The Visual C++ compiler treats include directives for precompiled headers in a special way, and often they are called stdafx.h, so I'll describe that treatment and see if that's the issue.
Each file using stdafx.h as the precompiled header will have this line at the top.
#include "stdafx.h"
Normally, this means the compiler looks for stdafx.h in the same source folder as the file that included it. However, when stdafx.h is the precompiled header, the Visual C++ compiler automatically includes the project's stdafx.h precompiled output, regardless of where the stdafx.h header or the output is. When the same project is compiled under GCC, GCC won't know where the file is if it's in another folder. You'll have to set the include path of the project appropriately so each preprocessor-related #include can find the proper file.
Normally, when an include file is located in an unknown folder specified only by a compiler [-I] directive, the include is written as:
#include <filename.h>
Unfortunately, Visual C++ doesn't let you use this notation for the precompiled header, and you have to rely on GCC following the include paths even for files specified with "" (double quotes). This behavior may or may not be in the C++ standard, but the one thing you'll want to make sure of is you don't have any extra/unintended stdafx.h files in the source tree, or you may run into even more unexpected compiled-code differences between VC++ and GCC.
The refactored code is missing certain includes. More than likely they are included in the precompiled header, stdafx.h, which usually isn't a good idea. Add the following includes to the bfs.cpp file, in between the "stdafx.h" include and the "using" declaration:
#include "stdafx.h"
#include <set>
#include <list>
#include <map>
#include <queue>
#include <iostream>
using namespace std;
Compiling...
bfs - 0 error(s), 0 warning(s)
Perhaps try:
#include <stdafx.h> // note angle brackets
This is different from the page you linked, which looks for stdafx.h in the current directory.
Or have you tried replacing that with the #includes in the original file?
For creating a new project , I recommend this :
New Project-> Empty Project
Then,
Project->Add New Item...-> C++ File (.cpp)
It's different from Win32 Console Application.