#include <Dbghelp.h> doesn't include the header - c++

If you include #include <Dbghelp.h> in, for example, a console C++ application, it will not bring any definitions from the header file and there are more or less similar compiler errors as if this header is not included at all.
Compiler errors looks like:
1>------ Build started: Project: ConsoleDump, Configuration: Debug Win32 ------
1> ConsoleDump.cpp
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(23): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(23): error C2146: syntax error: missing ';' before identifier 'Flags'
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(23): error C2065: 'Flags': undeclared identifier
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(23): error C2065: 'MiniDumpWithFullMemory': undeclared identifier
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(24): error C2065: 'MiniDumpWithFullMemoryInfo': undeclared identifier
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(25): error C2065: 'MiniDumpWithHandleData': undeclared identifier
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(26): error C2065: 'MiniDumpWithUnloadedModules': undeclared identifier
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(27): error C2065: 'MiniDumpWithThreadInfo': undeclared identifier
What's going wrong?

You must included <windows.h> before <DbgHelp.h>, and if the project uses "Stdafx.h", it must be included before everything else. The following is the correct order:
#include "stdafx.h"
#include <windows.h>
#include <Dbghelp.h>
Also make sure to link DbgHelp.lib to 'Project settings' > Linker > Input > 'Additional Dependencies'.

Related

Visual Studio Community 2015 MFC empty project doesn't compile

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

VS 2010 Compile error in SDK include headers

I had one problem when compiling code with VS2010. I got the following 100+ errors with the SDK headers. When I compiled the exact same code with VS2013 and V120, it worked fine.
I found similar problem on following link but it didn't work.
[Visual Studio 2010 and windows SDK 7.0a compilation error
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\oaidl.h(5472): error C2061: syntax error : identifier 'BSTR'
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\oaidl.h(5497): error C2061: syntax error : identifier 'BSTR'
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\oaidl.h(5507): error C2061: syntax error : identifier 'BSTR'
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\oaidl.h(5525): error C2061: syntax error : identifier 'BSTR'
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\oaidl.h(5544): error C2061: syntax error : identifier 'BSTR'
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\oaidl.h(5569): error C2061: syntax error : identifier 'BSTR'
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\oaidl.h(5579): error C2061: syntax error : identifier 'BSTR'
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml.h(303): error C2146: syntax error : missing ';' before identifier '_pchBuf'
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml.h(303): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml.h(303): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml.h(306): error C2146: syntax error : missing ';' before identifier '_pszFound'
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml.h(306): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml.h(306): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml.h(307): error C2146: syntax error : missing ';' before identifier '_pszExpected'
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml.h(307): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml.h(307): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml.h(410): error C2061: syntax error : identifier 'BSTR'
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml.h(535): error C2061: syntax error : identifier 'BSTR'
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml.h(596): error C2061: syntax error : identifier 'BSTR'
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml.h(599): error C2061: syntax error : identifier 'BSTR'
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml.h(602): error C2061: syntax error : identifier 'BSTR'
For Jonathan's question, the include part in the main cpp is as the following:
// Defines the entry point for the console application.
//
#include "stdafx.h"
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#include <math.h>
//----------------------------------------------------------------------------------
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <afx.h>
#include <time.h>
#include <stdlib.h>
#include <map>
#include <direct.h>
// insert specific include here
#include "recordSet.h"
#define roundX(x) ( floor(100.0 * x + 0.49 )) / 100 ;
#include "OutputAccumulator.h"
using namespace std;
Here is the code of stdfax.h:
#pragma warning(disable : 4786)
#if !defined(AFX_STDAFX_H__25F9CFE5_5C52_11D5_98E7_000255667102__INCLUDED_)
#define AFX_STDAFX_H__25F9CFE5_5C52_11D5_98E7_000255667102__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afx.h>
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdao.h> // MFC DAO database classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <iostream>
#define VERY_SMALL_VALUE 0.0000001
// TODO: reference additional headers your program requires here
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__25F9CFE5_5C52_11D5_98E7_000255667102__INCLUDED_)
Thanks for any insight!

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.

unidentified datatype in external header

I am attempting to write a .dll using a library that comes with some demo projects that run with no issues. When I attempt to #include a header, the compiler complains that certain datatypes are not defined. here is a sample of the errors generated
1>c:\program files (x86)\audiokinetic\wwise v2012.1.4 build 4260\sdk\include\ak\wwise\utilities.h(82) : error C2061: syntax error : identifier 'LPCWSTR'
1>c:\program files (x86)\audiokinetic\wwise v2012.1.4 build 4260\sdk\include\ak\wwise\utilities.h(90) : error C2061: syntax error : identifier 'LPCWSTR'
1>c:\program files (x86)\audiokinetic\wwise v2012.1.4 build 4260\sdk\include\ak\wwise\utilities.h(97) : error C2061: syntax error : identifier 'LPCWSTR'
1>c:\program files (x86)\audiokinetic\wwise v2012.1.4 build 4260\sdk\include\ak\wwise\utilities.h(107) : error C2061: syntax error : identifier 'LPCWSTR'
1>c:\program files (x86)\audiokinetic\wwise v2012.1.4 build 4260\sdk\include\ak\wwise\utilities.h(110) : error C2061: syntax error : identifier 'DWORD'
1>c:\program files (x86)\audiokinetic\wwise v2012.1.4 build 4260\sdk\include\ak\wwise\utilities.h(113) : error C2061: syntax error : identifier 'DWORD'
adding
#include <windows.h>
#include <atlstr.h>
to this external utilities.h file solves the problem, but as its a 3rd party header I don't believe I should be editing it, and considering these other demo projects #include the same header as I am, it seems to suggest that the problem lies elsewhere.
Can anyone think of a reason why this could be happening. The library I'm trying to use is Wwise (a sound engine). Here is a list of .libs im linking
AkSoundEngine.lib
AkMemoryMgr.lib
AkStreamMgr.lib
AkMusicEngine.lib
CommunicationCentral.lib
dxguid.lib
ws2_32.lib
dsound.lib
dinput8.lib
xinput.lib
Typically this is solved by changing the order your headers are included.
Assuming a file called header.h has the following:
LPCWSTR foo;
In you main:
// This is fail.
#include "header.h"
#include <windows.h>
Try:
// Success!
#include <windows.h>
#include "header.h"

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.