When i include GdiPlus.h,Pen class is undefined.
But GdiPlus.h includes GdiPlusPen.h
...
#include "GdiplusImageAttributes.h"
#include "GdiplusMatrix.h"
#include "GdiplusBrush.h"
#include "GdiplusPen.h"
#include "GdiplusStringFormat.h"
#include "GdiplusPath.h"
...
When i include GdiPlusPen.h myself, it works. Can i use it safely?
Question: is this because of my VC++ being express install?
8 days left until activation prompt :(
Anyone having same problem?
Windows XP sp-3, pentium-m centrino.
No, #including GdiplusPen.h directly isn't correct. The gdiplus classes live in a namespace named "Gdiplus". Either use that namespace explicitly (like Gdiplus::Pen) or make it look like this in your .cpp file:
#include <gdiplus.h>
using namespace Gdiplus;
Related
I am using Visual Studio Community 2017 to code c++. When I run the following code everything works fine.
#include "pch.h"
#include<Windows.h>
#include<Psapi.h>
#include <iostream>
#include <conio.h>
int main()
{
std::cout << "Really!! How do you do it?";
_getch();
}
But if I change the order of #includes by including psapi.h before Windows.h, compiler goes badass and throws 198 errors at me, which surprisingly(maybe only to me) includes Identifier "BOOL" is undefined.
Why is this happening?
Since Psapi.h's include tree is trivial, I'm going to exemplify. Everything relies on VStudio 2015 (Community) (v14.0.25431.01 Update 3) and Windows Kits 8.1 (? funny, because v10 is there too) files (with default env vars and preprocessor definitions):
BOOL is defined in minwindef.h (#157: typedef int BOOL;)
Psapi.h only includes one file (#27: #include <winapifamily.h>)
winapifamily.h doesn't include any other file
So, when reaching Psapi.h (#87: BOOL WINAPI EnumProcesses (...), the compiler doesn't know anything about BOOL, so it complains.
Windows.h includes minwindef.h (indirectly, via windef.h), and that's why it works when you include it before Psapi.h.
Personally, I think it's a bug in Psapi.h, since it's not self contained, but there might be a good reason (that I'm not aware of) for that. Anyway, if this is indeed a bug, it wouldn't be MS's 1st one :)
#include <Windows.h>
#include <WinSock2.h>
// main present just for rigorosity's sake
int main() {
return 0;
}
to answer the question, I know this is DATED but the issues persist today. You need the following:
#include "stdafx.h"
#include <stdbool.h>
#include <Windows.h>
#include <stdlib.h>
#include <psapi.h>
After stdlib.h was included, the errors were gone.
I have a native library for an Android app. When I load the entire C++ project in Android Studio, some errors are thrown by the IDE saying:
cannot resolve namespace std and cannot find any C++ headers.
#include <fstream>
#include <iostream>
#include <map>
using namespace std;
For all of the above code, fstream, iostream, etc is being marked red and shows cannot find. Any workaround to fix the above issue?
Whenever I include D3DX11Effect.h in my project, I get hundreds of errors from multiple different DirectX header files that do not give me errors when I do not include D3DX11Effect.h. These are my includes:
#include <string>
#include <dwmapi.h>
#include <iostream>
#include <Windows.h>
#include <vector>
#include <thread>
#include <chrono>
#include <string>
#include <sstream>
#include <TlHelp32.h>
#include <exception>
#include <memory>
#include <vector>
#include <D3D11.h>
#include <d3dx11.h>
#include <DXErr.h>
#include <D3DX11async.h>
#include <D3DX11Effect.h>
#include <D3Dcompiler.h>
#include <D3D11Shader.h>
#include <FW1FontWrapper.h>
#include "../Drawing/ImGUI/imgui.h"
#include "../Drawing/DirectX.h"
#include "../Drawing/imgui_dx11.h"
#include "../Drawing/ShaderFX.h"
#include "../Drawing/Renderer.h"
#include "Global.h"
I'm using Direct X 11 andWindows SDK version 10.0.16299.0. I've tried reinstalling DirectX with no luck. Here is an image of some of the errors I'm getting:
Any help is appreciated.
TL;DR: Read MSDN.
The DirectX SDK is deprecated, and the Windows 8.0 SDK, Windows 8.1 SDK, and Windows 10 SDK headers are newer than the headers that shipped in the legacy DirectX SDK. You are getting a mix of old headers and hew headers, which is why you are getting those errors.
The first thing to consider is if you need to use the legacy DirectX SDK at all. Ideally you just don't use it. This means avoiding the D3DX11 utility library which itself is also deprecated. You can find a number of open source replacements for that functionality listed in the article Living without D3DX, including the latest version of Effects for Dirct3D 11.
You can continue to use the legacy DirectX SDK mixed with modern versions of the Windows SDK, but you need to do it with some care as explained at the bottom of the MSDN page Where is the DirectX SDK?:
VC++ Directory include/lib paths must be in reverse traditional order so you get the newer headers where they conflict
You need to explicitly include d3d11.h and dxgi.h before you include d3dx11.h or you end up with the wrong version--which is exactly what happened above; you are using getting an outdated version of dxgi and/or d3dcommon.
For dxerr.h, build your own version as explained here because (a) it doesn't ship in the Windows SDK, and (b) the version that ships in the legacy DirectX SDK is not fully compatible with modern versions of Visual C++.
Note that the error buried in your image: C2440 static_cast cannot convert from const char[6] to char * in renderer.h has nothing to do with the issue above. This is due to the fact that modern C++11 rules on string literals disallow using them as non-const. You should fix the code, but you can also turn off strictstrings if you don't care about portability/conformance. In any case, take some time to read up on const correctness.
See The Zombie DirectX SDK for a complete dissection of what headers conflict, which ones are unique to the DirectX SDK, and which ones have any value for DirectX 11 games on modern versions of Windows.
You should review the various posts I've made in the past 8 years on this subject as well.
I can litterally not find which library/header this function is in, I've looked at so many examples of people using this function, but there are no results...
These are all the stuff I've included:
#include "Console.h"
#include "Direct3D9.h"
#include <string>
#include <cerrno>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
But still strtof comes up as "Error namespace "std" has no member "strtof""
What I'm trying to do:
flValue = std::strtof( vszArgs.at( 1 ).c_str( ), NULL );
pConVar->Set( flValue );
Visual Studio 2012 does not implement strtof.
Link to MSDN bug report which includes a suggested workaround.
You can find it in cstdlib when using C++11. The information can easily be found here : http://www.cplusplus.com/reference/cstdlib/strtof/?kw=strtof
My guess is that you aren't compiling using c++11.
1) Include stdlib.h
#include <stdlib.h> /* strtof */
from http://www.cplusplus.com/reference/cstdlib/strtof/
If that still doesn't work...
2) Make sure your compiler is C++11 or newer
It's new as of C++11 so if you have an older compiler it won't work.
If that still doesn't work...
3) Your compiler may just not support it
Visual C++ 2012 does not have full support for the C++11 standard. See the Visual Studio bug "Missing strtof, strtold, strtoll, strtoull functions from stdlib.h".
We don't yet have those functions in the CRT. We will consider adding them to a future version of Visual C++.
I have been using Visual Studio and I think I must have messed with some setting. I can't include basic things like <iostream>. How can I fix this?
#include <iostream> // for standard I/O
#include <string> // for strings
#include <iomanip> // for controlling float print precision
#include <sstream> // string to number conversion
#include <opencv2/imgproc/imgproc.hpp> // Gaussian Blur
#include <opencv2/core/core.hpp> // Basic OpenCV structures (cv::Mat, Scalar)
#include <opencv2/highgui/highgui.hpp> // OpenCV window I/O
using namespace std;
using namespace cv;
All the above lines are in red squiggle below. My guess is while trying to configure Visual Studio to use OpenCv, I messed with some setting.
More than likely, you forgot to add 'using namespace std' as pretty much nothing in iostream is really useful without it. If you are getting 'cant find ...', then you have a setup problem and should reinstall Visual Studio because the headers were not properly placed.
Hope this helps, feel free to post your code and I can tell you for sure what the problem is, but that is the most likely of them.