Cannot compile 3D point viewer in Visual Studio 2008 - visual-studio

Can someone help me ?I am trying to run the 3d point cloud viewer .However it shows me the following errors
Error 1 error C2144: syntax error : 'void' should be preceded by ';' c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h 1152 Viewer
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h 1152 Viewer
Error 3 error C2146: syntax error : missing ';' before identifier 'glAccum' c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h 1152 Viewer
Error 4 error C2182: 'APIENTRY' : illegal use of type 'void' c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h 1152 Viewer
Error 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h 1152 Viewer
Error 6 error C2144: syntax error : 'void' should be preceded by ';' c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h 1153 Viewer
Error 7 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h 1153 Viewer
and so on ...
Beginning of my code is :
#include <cstdlib>
#include <GL/glut.h>
#include <cmath>
#include "arcball.h"
#include <vector>
#include <iostream>
#include <fstream>
using namespace std;
Can someone please tell me what is going wrong?

Well, the first reported error is on the first line that declares a function with the WINGDIAPI modifier. Apparently, this is declared in wingdi.h. However, I'm not sure if you're meant to #include that directly, or whether there's a more formal recommendation for compiling opengl code in the windows environment. I'll have a hunt around.
The page on MSDN discussing the necessary headers for OpenGL work are a bit vague, but I take:
The Windows functions that support Microsoft's implementation of OpenGL in Windows must include the header file Windows.h.
To mean that you ought to include windows.h first.
Really? If I create a blank C++ project in VS2008, create an empty cpp file, copy and paste your includes in, and hit compile, I get exactly the errors you described. If I change my includes to:
#include <cstdlib>
#include <windows.h>
#include <GL/gl.h>
#include <cmath>
#include "arcball.h"
#include <vector>
#include <iostream>
#include <fstream>
Then the first reported error I get is that it can't find "arcball.h" (hardly unexpected). Are you still getting the same errors once windows.h is included?

Related

How do I deal with both winnt.h and ntstatus.h both in the WDK?

I am compiling a program that gets an error because both winnt.h and ntstatus.h are included in the WDK. I compiled with preprocess to a file and found this:
#line 1 "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\um\\winnt.h"
and this:
#line 1 "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\shared\\ntstatus.h"
Here are my includes:
#include <windows.h>
#include <winbase.h>
#include <winnt.h>
Here is the error I get:
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared\ntstatus.h(66,14): warning C4005: 'STATUS_WAIT_0': macro redefinition
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(2496): message : see previous definition of 'STATUS_WAIT_0'
Is there a define I need to use to tell VS not to open both?
I was using the dokan library. I found that dokan.h includes ntstatus.h and there is a define called WIN32_NO_STATUS to take care of that.
Add UMDF_USING_NTSTATUS define

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

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.

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.

Removing Include Errors

I am getting a bunch of errors as follows:-
Error 1 error C2144: syntax error : 'void' should be preceded by ';' c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h 1152 Viewer
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h 1152 Viewer
Error 3 error C2146: syntax error : missing ';' before identifier 'glAccum' c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h 1152 Viewer
Error 4 error C2182: 'APIENTRY' : illegal use of type 'void' c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h 1152 Viewer
Error 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h 1152 Viewer
Error 6 error C2144: syntax error : 'void' should be preceded by ';' c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h 1153 Viewer
Error 7 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h 1153 Viewer
This is all that I include in the beginning of my code :-
#include <cstdlib>
#include <windows.h>
#include <GL/glut.h>
#include <cmath>
#include "arcball.h"
#include <vector>
#include <iostream>
#include <fstream>
using namespace std;
It is interesting though that when I click on the first error it points me to the line
WINGDIAPI void APIENTRY glAccum (GLenum op, GLfloat value);
in gl.h .I am not even including that file.Where are the errors coming from?
PS. dont know if itis important but I have saved the file as a .cpp.
Ok this is weird but I completely remove all the headers and it still shows me this error!!
You are probably missing an include file WinGDI.h. gl.h is most likely included by the file <GL/glut.h>
#include <cstdlib>
#include <windows.h>
#include <WinGDI.h> // <--------------------
#include <GL/glut.h>
#include <cmath>
#include "arcball.h"
#include <vector>
#include <iostream>
#include <fstream>

Resources