C++ #include not working in Microsoft Visual Studio 2010 - 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.

Related

Where is '__find_end' present in Visual Studio 19 C/C++ Development Tools?

I was trying to compile an old code, and received the following error:
error G1A4676F8: no member named '__find_end' in namespace 'std'
I searched online and found it is defined in stl_algo.h, which I couldn't find in my Windows system. Also, the documentations were of libstdc++4 and earlier.
The code compiles fine on https://godbolt.org/ with all MSVC versions.
The include statements are:
#include <string>
#include <algorithm>
#include <iterator>
#include <ostream>
#include <iomanip>
#include <stdexcept>
The compiler shows an alternative as find_end defined in algorithm but I am not sure if __find_end has the same functionality as find_end.
So, my question is, is __find_end deprecated?
If not, where can I find it's declaration in Windows?
If yes, what are my alternatives? Is find_end a perfect substitute for __find_end?

Cannot resolve namespace std in Android Studio

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?

line_descriptor.hpp is included, but KeyLine and also BinaryDescriptor are still undefined

I have been using OpenCV 3.0 that are combined with the extra modules using CMake 3.5. I am using Visual Studio 2012 32bit as my IDE.
However, i cannot seem to use both KeyLine and also BinaryDescriptor. They give me error which is "identifier KeyLine is undefined". I have set the Paths and also library setting.
#include <opencv2/opencv.hpp>
#include <opencv2/line_descriptor.hpp>
#include <iostream>
using namespace std;
using namespace cv;
int main( void ) {
Ptr<BinaryDescriptor> bd = BinaryDescriptor::createBinaryDescriptor();// this line gives error
vector<KeyLine> lines; // same as this
}
I have tried the other header, for instance the tracking.hpp. I am able to define:
Ptr<Tracker> tkr;
Without having the Tracker giving me error.
Anyone know if the error is caused during CMake process or i miss out something?
I just had the same problem, and stumbled upon your question.
The answer I just found out is you have to add,
using namespace line_descriptor;
at the top along with cv namespace.Got this hint from line_descriptor.hpp source code.

VC++ 10.0 express gdi+ GdiPlusPen.h header

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;

visual studio - invalid std::string debugger output in Release mode

There's nothing fancy going on in this program, but I get garbage output. Here are the header files I'm including, in case that's relevant.
#include <cstdlib>
#include <iostream>
#include <windows.h>
#include <vector>
#include <string>
#include <sstream>
And I'm using Visual Studio 2008 on Windows XP.
Note that if I print the string to stdout, it prints "test" perfectly fine.
Sometimes the debugger will have trouble picking up proper values if you've compiled in Release mode. The compiler might swap around operations or move values to registers, etc.