I get errors for including vector - visual-studio

I'm trying to write a simple program to display shapes using 3dCoin
however when starting to debug the program it gives me 51 errors in cmath file in which I did not change anything in it since it is a standard file.
#include <Inventor/Win/SoWin.h>
#include <Inventor/Win/viewers/SoWinExaminerViewer.h>
#include <Inventor/nodes/SoSeparator.h>
#include <vector>// when I include vector it gives me the errors
int main(int, char ** argv) {
HWND window = SoWin::init("0.off");
if (window == NULL) exit(1);
SoSeparator * root = new SoSeparator;
root->ref();
SoWinExaminerViewer *viewer = new SoWinExaminerViewer(window);
viewer->setSize(SbVec2s(640, 480));
viewer->setSceneGraph(root);
viewer->show();
SoWin::show(window);
SoWin::mainLoop();
delete viewer;
root->unref();
return 0;
}
The type of errors I'm getting are:
Severity Code Description Project File Line Suppression State
Error C2589 '(': illegal token on right side of '::' project c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.10.25017\include\cmath 19
Severity Code Description Project File Line Suppression State
Error C2440 'type cast': cannot convert from 'float' to 'unknown-type (__cdecl *)(float)' project c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.10.25017\include\cmath 19
and many more.....
Can anyone help find the reason I have been trying to find a solution for a while but could not understand the reason behind such errors?

I've received exactly the same error with you. More than 30 lines of cmath and also int8_t type redefinition error. I've solved this problem by putting each of my header files above Inventors and then I've put #define HAVE_INT8_T above everything in my source files due to the int8_t type redefinition error. Then, compile error is gone.

Related

error RC2247: Symbol name too long (winnt.h)

I'm getting an RC2247 error (Symbol name too long) when attempting to display the dialogs in a Win32 app. The error is occurring in this file:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\winnt.h
This worked fine under VS2015. The error started when I upgraded to VS2017.
I have seen the following posts, they don't appear to be relevant because they pertain to prsht.h:
RC2247 : Cannot open Rc file : Resource explorer cannot load resource ; Load failed
http://social.msdn.microsoft.com/Forums/en-US/vcprerelease/thread/4a648d6a-ea81-44d3-89c2-57fa5caa6fd6
The error disappears if I comment out the entire resource.rc file. The error occurs if the RC contains the single line:
#include <winnt.h>
When I click on "Edit code"", nothing happens.
I am grateful for any suggestions.
We must not include windows.h or winnt.h to .rc file - this headers - for are for c/c++ compilers and not designed for RC (resource compiler which process .rc file). as result if we include such files we may get errors.
We need include #include <winres.h> to .rc files. this file specially designed for the RC compiler. Internally it included:
#include <winuser.rh>
#include <commctrl.rh>
#include <dde.rh>
#include <winnt.rh>
#include <dlgs.h>
#include <winver.h>
and define some macros.
All standard windows definitions, which we need/use in rc file - exist in winres.h (and it subincludes). From another side in it no extra symbols/definitions wich exist in windows.h - it's not needed for rc and some time can cause errors.
So simply #include <winres.h> at the beginning of resource files and all will be OK.
I have run into this complaint rc2247 when trying to edit the rc file in a project compiled in vs2010. This had been upgraded from vs2050. I found that if I chose to open the .sin file via 'version selector' instead of going straight to vs2010, then it still opens in vs2010 but there is no problem in editing the rc. I don't pretend to understand !
CalendarMan

Error during compilation of the code using make file in VC++

I am using below snippet in my code.
//from Vista WinNT.h
//
typedef struct _TOKEN_MANDATORY_LABEL {
SID_AND_ATTRIBUTES Label;
} TOKEN_MANDATORY_LABEL, *PTOKEN_MANDATORY_LABEL;
When I build this through VS2005 it give no error. But when I am building using make file i am getting below error in cmd:
Test.cpp(337) : error C2011: '_TOKEN_MANDATORY_LABEL' : 'struct' type redefinition
C:\Program Files\Microsoft SDKs\Windows\v6.1\include\winnt.h(7351) : see declaration of '_TOKEN_MANDATORY_LABEL'
I am using Opus software to use make file. Please let me know if I am missing something or needs to add some libs to overcome this error.

error C4430: missing type specifier - int assumed?

I have written a callback method and when I am trying to compile the project in vs2012, I am getting the following error:
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2143: syntax error : missing ',' before '&'
the both error present in same line.
These are the following code which I am trying:
#include <windows.h>
#include "atlstr.h"
///////////////////////////////////////////////////////////////////////////////
class CInf;
typedef BOOL (*PENUMDEVCALLBACK)(CInf* inf, const CString& devname, const CString& instsecname, const CStringArray& devid, PVOID context, DWORD& code);
I think the error will be present in CStringArray& argument because when I include the afxcoll.h.
the fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>.
When I removed the windows.h. the above error gone but I need windows.h header also.
Any idea how to include windows.h and afxcoll.h in same file.
It is not possible to include only isolated parts of the MFC. When you want to use CStringArray you Need to include the afx.h or afxwin.h file.
It is possible to use CString alone. If you just want an Array of CString and you don't Need the complete MFC than it is easier to use std::vector. CString works perfect with all STL container.

`Ole2.h` include causing an error

I'm using Microsoft Visual C++ Express 2012. I have the following as part of my header setup:
#include <windows.h>
#include <Ole2.h>
When I include windows.h on it's own there's no build errors, but when I include Ole2.h either with windows.h or without windows.h I get the following compiler error:
Error 1 error C2628: '_RPC_ASYNC_NOTIFICATION_INFO::$UnnamedClass$0x1c06c483$29$' followed by 'int' is illegal (did you forget a ';'?) C:\Program Files (x86)\Windows Kits\8.0\Include\shared\rpcasync.h 127 1 Test`
Any ideas what might be going wrong? Ultimately I'm trying to write some simple code to interface with Kinect, but even without any Kinect includes present the above error is still generated.
When I double click the error I am taken to rpcasync.h and the following code:
#if !defined(RPC_NO_WINDOWS_H)
//
// Notification by window message
//
struct {
HWND hWnd;
UINT Msg;
} HWND; //<<<-------- the error points here (HWND is underlined in red)
#endif // RPC_NO_WINDOWS_H
PS The reason I'm including Ole2.h at all is because I'm following this tutorial.

Linking to winmm.dll in Visual Studio 2013 Express for mciSendString

I am trying to use mciSendString in visual studio express 2013 (Visual C++) but I keep getting an error
Error 1 error C3861: 'mciSendStringA': identifier not found
I assume this i because I have not linked to the correct dll, but I cannot find any details online or on msdn about how to link to the dll. It seems quite strange that there wouldn't be more obvious documentation about this. Can someone tell me how to link to the dll?
EDIT:
Here is the code I am trying to run:
#include <Windows.h>
#include <iostream>
#include <mmsystem.h>
extern char command1[] = "open C:\\boing.mp3 type MPEGVideo alias 0";
extern char command2[] = "play 0 from 0";
int main()
{
mciSendStringA(command1, NULL, 0, 0);
mciSendStringA(command2, NULL, 0, 0);
}
To make mciSendString() to work, you need to link to winmm.lib.
Just adding winmm.lib to Project Properties > Linker > Input > Additional Dependencies will be fine.
Looking at mmsystem.h (admittedly from the V7.1A Windows SDK, which is the most recent I have installed), I can see that there's a #ifdef _WIN32 block in there. If _WIN32 is not defined, then mciSendStringA is not declared. Instead mciSendString is declared.
Check your project options and ensure that both WIN32 and _WIN32 are defined. I'm guessing that you started from a console project, rather than a Windows Application project, and that at least one of those isn't defined.

Resources