Why does including several libraries throw Runtime Error(SIGILL)? - c++

I was getting SIGILL Runtime Error on one of my codes.
But then i noticed that just changing the libraries used made it run normally.
Previous code(throws Runtime Error on C++14):
#pragma GCC target("avx2")
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <chrono>
#include <random>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
Modified version(Gave AC on C++14):
#include<bits/stdc++.h>
What might be the reason for this?

Related

identifier "CvRTrees" is undefined

I'm using openCV-3.2.0 and getting an identifier undefined error when initializing the line :
CvRTrees rtrees;
I think i have added all the necessary header files. So why am i getting this error?
#include <stdio.h>
#include<conio.h>
#include <opencv/cv.h>
#include <opencv2/highgui/highgui.hpp>
#include <opencv/cvaux.h>
#include <opencv/ml.h>
#include <opencv2/core/core.hpp>
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <math.h>
#include <windows.h>
#include <string>
#include <stdlib.h>
#include <exception>
#include <array>
#include "opencv2/ml/ml.hpp"
using namespace std;
using namespace cv;
This class exists in OpenCV 2.4.x, However it is not available in newer versions of OpenCV like 3.2.0. Check here the list of all cv::ml classes for OpenCV 3.2.0. I suggest you to use RTrees instead. To do this you do not need to include all headers, just include the machine learning module:
#include "opencv2/ml/ml.hpp"

why #include <iostream> is not used in driver development

#include <DriverSpecs.h>
_Analysis_mode_(_Analysis_code_type_user_code_)
#define INITGUID
//#include<iostream>
#include <windows.h>
#include <strsafe.h>
#include <cfgmgr32.h>
#include <stdio.h>
#include <stdlib.h>
#include "public.h"
When I tried to use <iostream> in a sample driver solution I got an error.
I'd like to know if is it possible to get input or output while a driver is running.

std::getline get error in JNI

I am using jni and want to read file from path, i used:
while (std::getline(file, str)) {
...
}
but it get an error : Function 'getline' could not be resolved, i have added:
#include <vector>
#include <string.h>
#include <jni.h>
#include <fstream>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <iostream>
and they are Ok. How do i resolved this problem? Please help me.
use:
#include <string>
instead of:
#include <string.h>
The latter one is the C variant and will not have the std namespace. Also see:
Difference between <string> and <string.h>?

Difference between memory standard header and an include file

I am new to C++ and I am debugging one problem where there is a allocate.h file which is included by main.cpp file. Now the allocate.h file has first line like this : #include <memory.h>. and when I try to compile main.cpp I get an error message saying
Microsoft Visual Studio 11.0\ VC\ include\ typeinfo (153) : error
C2504 exception base class undefined
But when I change that first line to : #include <memory> then main.cpp compiles fine. Thats when I started to search the web for difference between these two styles of including files and I haven't found any detailed explanation yet. If anybody can explain the difference between including a .h file and a memory standard header, that would be really helpful.
Is it because #include<memory> is more thread safe ? or is it because its just the way in c++ to include files.
Also I am using cmake to include my project in the llvm's generated solution. When generating my .vcxproj file it includes _HAS_EXCEPTIONS=0; in the <PreprocessorDefinitions> tag in it. If I use the earlier declaration #include<memory.h> and remove _HAS_EXCEPTIONS=0; from the <PreprocessorDefinitions> tag then the project compiles fine. How is all this connected ? Can somebody help me connect the dots ?
<memory.h> and <memory> aren't different styles, they are two completely different headers.
<memory.h> looks like it's an internal header used by MS's C library, you shouldn't be including it, use the standard C++ header <memory>.
After writing this answer I found this SO question that I think is relevant.
This is nothing to do with thread safety AFAIK. The standard C++ headers are as below from the reference, 17.6.1.2 Headers:
Table 13 — C++ library headers
<algorithm> <fstream> <list> <regex> <typeindex>
<array> <functional> <locale> <set> <typeinfo>
<atomic> <future> <map> <sstream> <type_traits>
<bitset> <initializer_list> <memory> <stack> <unordered_map>
<chrono> <iomanip> <mutex> <stdexcept> <unordered_set>
<codecvt> <ios> <new> <streambuf> <utility>
<complex> <iosfwd> <numeric> <string> <valarray>
<condition_variable> <iostream> <ostream> <strstream> <vector>
<deque> <istream> <queue> <system_error>
<exception> <iterator> <random> <thread>
<forward_list> <limits> <ratio> <tuple>
As others have said, memory.h is not one of them.
For completeness, here are the C++ standard headers for C library facilities.
Table 14 — C++ headers for C library facilities
<cassert> <cfloat> <cmath> <cstddef> <ctgmath>
<ccomplex> <cinttypes> <csetjmp> <cstdint> <ctime>
<cctype> <ciso646> <csignal> <cstdio> <cuchar>
<cerrno> <climits> <cstdarg> <cstdlib> <cwchar>
<cfenv> <clocale> <cstdbool> <cstring> <cwctype>

Weird VC++ Intellisense Behavior

Intellisense is broken with this code, everything is undefined to Intellisense from tree header:
#include "tree.h"
#include <iostream>
#include <ctime>
#include <string>
#include <list>
But when I move my own bst implementation header file down a bit, Intellisense starts working again.
#include <iostream>
#include <ctime>
#include <string>
#include <list>
#include "tree.h"
Why is this?