Using std::function<void> on visual studio 2013 - xcode

I am converting my project from mac os x (xcode) to windows (visual studio 2013).
But i am having problems when i try to use the std::function.
As an example i declared.
std::function<void()> processFunc;
But i get several errors:
Error 1 error C2039: 'function' : is not a member of 'std' ...github\oglengine\engine\game.h 39 1 Engine
Error 2 error C2143: syntax error : missing ';' before '<' ...github\oglengine\engine\game.h 39 1 Engine
Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ...github\oglengine\engine\game.h 39 1 Engine
On XCode i needed to enable the c++11, but from what i saw on my research the VS 2013 have the C++11 enables.
My only C++ include is the iostream
Should i add another include?

I believe you need to #include <functional> in VS.

Related

Visual Studio error when ITK and VTK is used

I am doing a project in visual studio 2015When i included ITK and compiled everything ,some errors are occurring
Error C3861 '_beginthreadex': identifier not found
Error C2039 '_time64': is not a member of '`global namespace''
Error C3861 '_time64': identifier not found
Error C3861 '_mktime64': identifier not found
Error C3861 '_mktime64': identifier not found
Error C3861 '_gmtime64_s': identifier not found
Error C3861 '_localtime64_s': identifier not found
Error C3861 '_mktime64': identifier not found
Error C3861 '_localtime64_s': identifier not found
Error C3861 '_gmtime64_s': identifier not found
Error C2039 '_time64': is not a member of '`global namespace''
Error C3861 '_time64': identifier not found
Error C3646 'm_nLastAnimTime': unknown override specifier
Error C4430 missing type specifier - int assumed. Note: C++ does not
support default-int
Error C3646 'm_ActiveTime': unknown override specifier
Error C4430 missing type specifier - int assumed. Note: C++ does not
support default-int
Error C3646 'm_clkLastTime': unknown override specifier
But i tried including Visual studio/VC/Include and Visual Studio/VC/bin to the Additional Include Directories,still it is showing the same errors.
I also tried changing the Use of MFC and c++ ->code generation ->Runtime Library in configuration properties as well.
I referred this link also,but my problem is not solved.
So i thought may be because of vs2015 instalation problems and tried to build a new project using VTK and ITK in Visualstudio 2017,In there also the same errors are occurring.I have been stuck for weeks ,Can anyone give a solution for my problem?
Are you using this procedure to build ITK and VTK? Are you following this guide to build your own application? Using CMake is the only supported way of using ITK and/or VTK.
If you cannot use CMake, a workaround is to build a hello world example using CMake and then copy include paths and list of libraries to your main Visual Studio application.

Using directX 11 in Visual Studio 6.0

I want use include files
#include <d3d11.h>
#include <d3dx11.h>
#include <d3dcompiler.h>
#include <xnamath.h>
in visual studio 6.0.
But when i compile .cpp i we got this error:
:\Users\8up tuotlo\Desktop\Visual C++ 6.0 Proects\11\Article1\Article1.cpp(28) : error C2146: syntax error : missing ';' before identifier 'CD3D11_DEFAULT'
:\Users\8up tuotlo\Desktop\Visual C++ 6.0 Proects\11\Article1\Article1.cpp(28) : error C2146: syntax error : missing ';' before identifier 'CD3D11_DEFAULT'
When i include:
#include <d3d9.h>
#include <d3dx9.h>
All normally compile.
What is this thing?
Check the compiler support for recent versions of the Windows SDK. I suspect that VC++6 is no longer supported (it is over 15 years since it was released, with six releases since then).

How to include a .h file correctly in VC++?

I have a very simple C++/CLI window form program which is 100% working alright.
Since I want to add call internet explorer when I click a button on my window form, I add "ONE LINE of code" for testing purpose.
I add #include "Shellapi.h" under #pragma once. After that, VS gives me 500 lines of an error message.
My question is that I am only adding a .h file into my program. Why there will cause any problem? Do I miss something?
===========The first few lines of the error message===============
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\Shellapi.h(56): error C2065: 'HDROP' : undeclared identifier
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\Shellapi.h(56): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\Shellapi.h(59): error C2146: syntax error : missing ';' before identifier 'DECLSPEC_IMPORT'
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\Shellapi.h(59): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\Shellapi.h(59): error C2146: syntax error : missing ';' before identifier 'UINT'
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\Shellapi.h(59): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\Shellapi.h(59): error C2146: syntax error : missing ';' before identifier 'STDAPICALLTYPE'
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\Shellapi.h(59): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Several things:
You should #include <windows.h> in any windows program
You should include any system file - like shellapi.h - using brackets (<>) instead of quotes (""), e.g. #include <shellapi.h>
If you're compiling from the command line, it's a good idea to run "vcvars32.bat" (or equivalent) to set your command-line environment for Visual Studio.
I believe you forgot to #include <windows.h> before #include <shellapi.h>
Generally, (or atleast in my personal experiences), when you are bombarded with a wall of errors after including a header, your missing <windows.h> or some other header.

Visual Studio 2010 source annotation keywords cause name clashes

After having converted a project from Visual Studio 2005 to Visual Studio 2010, it appears the project doesn't build anymore and spits out tons of C2059 errors like:
`error C2059: syntax error : 'type'
We're using Visual Studio 2010 Professional which doesn't provide static code analysis.
Here is the full log for the compilation of 1 C file for reference:
1>------ Build started: Project: VoHR, Configuration: Debug Win32 ------
1> AKAsynch.c
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(88): error C2059: syntax error : 'type'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(107): error C2059: syntax error : '}'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(119): error C2059: syntax error : 'type'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(139): error C2059: syntax error : '}'
I tracked down the reason of those sudden compiler errors.
In the great tradition of windows.h it appears that Microsoft introduced tokens that cause name clashes with our codebase.
In our precise case, we had:
#define Null (void*)0
Somewhere in our code, we need to use the offsetof macro and to make it available we #include <stddef.h>
I tracked down stddef.h in turns includes crtdefs.h which ends up including sal.h where our Null macro seems to clash with source code annotation in MS headers...
As a workaround, we did:
#if defined(_MSC_VER) && _MSC_VER >= 1600
#pragma push_macro("Null")
#undef Null
#endif
#include <stddef.h>
#if defined(_MSC_VER) && _MSC_VER >= 1600
#pragma pop_macro("Null")
#endif
Our use of Null as a macro is arguable, still I would have expected MS to find a way to avoid clashes with existing code bases.
Hope that helps those facing the same issue.

How to solve build errors using VS 2010 Ultimate on 32bit XP Sp3

Installed VS2010 Ultimate on my desktop workstation - Dell Precision T3500 (Windows 7 64bit OS), and on my IBM ThinkPad R51 (Windows XP Sp3 32bit).
I am having problems building solutions on the StinkPad, and cannot figure out why. As listed below, the build output for a compiler built ADO library lists the following errors:
c:\wpds\debug\msjro.tlh(196): error C2146: syntax error : missing ';' before identifier 'ConflictTables'
c:\wpds\debug\msjro.tlh(196): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\wpds\debug\msjro.tlh(196): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\wpds\debug\msjro.tlh(224): error C2146: syntax error : missing ';' before identifier 'GetConflictTables'
c:\wpds\debug\msjro.tlh(224): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
I have checked to make sure that all include, exe, and library paths are correct for all projects and solutions. Any insight will be greatly appreciated.
Thanks
Bill
I encountered this same problem when compiling for the first time with a new version of msado15.dll. There are dependencies between msado15.dll and msjro.dll, as evidenced by these lines at the top of msjro.tlb:
// Cross-referenced type libraries:
//
// #import "C:\Program Files (x86)\Common Files\System\ado\msado15.dll"
//
In my case, the problem arose because I'm building my app on Windows 7, and the SP1 update includes a breaking change in msado15.dll that will cause the application to fail on Windows XP. When I fixed this problem using this KB, my msado dll problems were fixed but my msjro.tlb stopped compiling.
There is probably a way to update msjro to reference the desired/correct msado (in my case, msado60_Backcompat.tlb as installed in the KB), but if you're using CADODatabase classes defined in ado2.cpp and ado2.h, and if you're not using jet-specific features, a simpler fix is to just comment-out the portions of ado2.h and ado2.cpp that reference jet.
I just commented out this line in ado2.h:
//#import <MSJRO.DLL> no_namespace rename("ReplicaTypeEnum", "_ReplicaTypeEnum")
and also #ifdef'd out all of the implementations of CJetEngine methods in ado2.cpp, and that worked for me.
Good luck!
I had this problem too. Then I compared the MSJRO.TLH created on WinXP to the one created on Win7. On WinXP the declaration was
ADODB::_RecordsetPtr ...
on Win7 it was
_RecordsetPtr ...
I guessed that the problem might be related to namespaces. MSADO15.TLH defines a namespace -"ADODB". So I placed:
using namespace ADODB;
before my import of the Jet.
#import "MSJRO.DLL"
This got rid of the errors for me.

Resources