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>
Related
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.
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>
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.
I'm usual to build with consider warning as error. I'm using Boost C++ 1.54.0 with MinGW 4.8.1, in particular I'm using ptree.
#include <iostream>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
using namespace std;
int main() {
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
}
This simple program cause the following errors:
typedef 'cons_element' locally defined but not used [-Wunused-local-typedefs] line 228, external location: \boost\tuple\detail\tuple_basic.hpp
typedef 'Str' locally defined but not used [-Wunused-local-typedefs] line 38, external location: \boost\property_tree\detail\xml_parser_write.hpp
typedef 'Str' locally defined but not used [-Wunused-local-typedefs] line 72, external location: \boost\property_tree\detail\xml_parser_write.hpp
typedef 'T_must_be_placeholder' locally defined but not used [-Wunused-local-typedefs] line 37, external location: \boost\bind\arg.hpp
Is a way to ignore this warnings?
gcc allows ignoring specific warnings since 4.6
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
...
...
#pragma GCC diagnostic pop
there are still some warnings that cannot be turend off this way, but it works for most
or do it like the other mentioned and add -Wno-unused-local-typedefs to the commandline
I'm trying to write and compile some C code which I would use frm MATLAB with VS 2012
Here is my header file:
#ifndef _DLLTEST_H_
#define _DLLTEST_H_
#include <iostream>
#include <stdio.h>
#include <windows.h>
extern "C" __declspec(dllexport) int Add(int a, int b);
#endif
And here is implementation:
#include "stdafx.h"
#include "nureader.h"
extern "C" __declspec(dllexport) int Add(int a, int b)
{
return (a + b);
}
Compilation goes fine, but when I try to load DLL to MATLAB, I getting a strange error:
>> [a,b] = loadlibrary('nureader.dll', 'nureader.h')
Error using loadlibrary (line 419)
Failed to preprocess the input file.
Output from preprocessor is:nureader.h
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\eh.h(27) : fatal error C1189: #error : "eh.h
is only for C++!"
Take a look at VS output
fatal error C1189: #error : "eh.h is only for C++!"
You want to write a C library, right? so don't include C++ in it. or compile with G++ but since you're using windows I don't think you have that option...
In any case, track down what includes "eh.h" and try without it. If it builds without it - great, if not - you will need to only isolate the C portion of your program. By looking at the code, you don't seem to need anything more than
#include <stdio.h>
#include <windows.h>
So try that.