error C4430: missing type specifier - int assumed? - windows

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.

Related

I get errors for including vector

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.

Unresolved Error while using stbi_set_flip_vertically_on_load function

I get unresolved symbol error while using stbi_set_flip_vertically_on_load function.
I have added the #include <stb_image.h> file as header , do i need to do something else also ?
stb_image - v2.19
#include <stb_image.h>
stbi_set_flip_vertically_on_load(true); // this gives unresolved symbol error though
You also need to compile stb_image. This should work:
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>

Omnet++ make issues

I get the following error when compiling omnetpp-5.4.1, do I need to uninstall the libgles2-mesa-dev package ?
In file included from /usr/include/GL/gl.h:2055:
/usr/include/GL/glext.h:469:19: error: typedef redefinition with different types
('ptrdiff_t' (aka 'int') vs 'khronos_intptr_t' (aka 'long'))
typedef ptrdiff_t GLintptr;
^
/usr/include/GLES3/gl31.h:74:26: note: previous definition is here
typedef khronos_intptr_t GLintptr;
^
In file included from osgviewer.cc:27:
In file included from /usr/include/arm-linux-gnueabihf/qt5/QtGui/QOpenGLFunctions:1:
/usr/include/arm-linux-gnueabihf/qt5/QtGui/qopenglfunctions.h:60:16: error:
cannot combine with previous 'double' declaration specifier
typedef double GLdouble;
^
/usr/include/osg/GL:129:38: note: expanded from macro 'GLdouble'
#define GLdouble double
^
3 errors generated.
This seems to be an issue with the system headers. If you do not need OpenSceneGraph/osgEarth support, you can turn it off in the configure.user file and the re-configure/rebuild omnet. That will exclude the OSG specific files from the build process. (if you do not need the graphical environment (Qtenv) you can even turn off that in the configure.user which will prevent also linking with Qt libs).

'char' followed by 'char' is illegal in stdint.h line 21

I've been learning CPP a lot recently, this is my first GUI application. It was going well, got buttons and stuff to work.
But after doing little changes to storing and loading resources, VisualStudio starts through this collection of errors from the standard library
Error C2632 'char' followed by 'char' is illegal GUI stdint.h 21
Error C2589 'unsigned': illegal token on right side of '::' GUI cstdint 12
Error C2144 syntax error: 'char' should be preceded by ';' GUI cstdint 12
Error C2873 'unknown-type': symbol cannot be used in a using-declaration GUI cstdint 12
Error C2589 'unsigned': illegal token on right side of '::' GUI cstdint 32
Error C2144 syntax error: 'char' should be preceded by ';' GUI cstdint 32
Error C2873 'unknown-type': symbol cannot be used in a using-declaration GUI cstdint 32
These are all STD files, and I promise I haven't edited them.
The first error char followed by char is thrown on this line
typedef unsigned char uint8_t;
And the rest of the errors are related to that as they are trying to use uint8_t.
Its been working away fine, then just on 1 compile, visual studio decided its own STD files have errors.
I'm not using stdint.h or cstdint (don't know if they are included automatically)
Includes
#using <mscorlib.dll>
#include <windows.h>
#include <urlmon.h>
#include <process.h>
#include <stdio.h>
#include <vcclr.h>
#pragma comment(lib, "urlmon.lib")
#pragma comment(lib, "Wininet.lib")
#include <Wininet.h>
#include <string>

`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.

Resources