g++
How to check if compiled code uses SSE and AVX instructions?
Under Linux, you could also decompile your binary: objdump -d YOURFILE > YOURFILE.asm Then find all SSE instructions: awk ‘/[ \t](addps|addss|andnps|andps|cmpps|cmpss|comiss|cvtpi2ps|cvtps2pi|cvtsi2ss|cvtss2s|cvttps2pi|cvttss2si|divps|divss|ldmxcsr|maxps|maxss|minps|minss|movaps|movhlps|movhps|movlhps|movlps|movmskps|movntps|movss|movups|mulps|mulss|orps|rcpps|rcpss|rsqrtps|rsqrtss|shufps|sqrtps|sqrtss|stmxcsr|subps|subss|ucomiss|unpckhps|unpcklps|xorps|pavgb|pavgw|pextrw|pinsrw|pmaxsw|pmaxub|pminsw|pminub|pmovmskb|psadbw|pshufw)[ \t]/’ YOURFILE.asm Find only packed SSE instructions (suggested by @Peter Cordes in comments): awk ‘/[ \t](addps|andnps|andps|cmpps|cvtpi2ps|cvtps2pi|cvttps2pi|divps|maxps|minps|movaps|movhlps|movhps|movlhps|movlps|movmskps|movntps|movntq|movups|mulps|orps|pavgb|pavgw|pextrw|pinsrw|pmaxsw|pmaxub|pminsw|pminub|pmovmskb|pmulhuw|psadbw|pshufw|rcpps|rsqrtps|shufps|sqrtps|subps|unpckhps|unpcklps|xorps)[ \t]/’ YOURFILE.asm Find all SSE2 instructions (except MOVSD and CMPSD, which were first introduced in 80386): awk ‘/[ … Read more
What does the “explicit qualification in declaration” error message mean?
tl;dr: Drop the namespace from before the function name. I ran into the same issue. I had some source that compiled using MS Visual Studio but using g++ in Linux it gave me: … error: explicit qualification in declaration of ‘… It appears that this error occurs when the implementation is already inside namespace foospace … Read more
Fatal error: iostream: No such file or directory in compiling C program using GCC
Neither <iostream> nor <iostream.h> are standard C header files. Your code is meant to be C++, where <iostream> is a valid header. Use a C++ compiler such as clang++ or g++ (and a .cpp file extension) for C++ code. Alternatively, this program uses mostly constructs that are available in C anyway. It’s easy enough to … Read more
When did “and” become an operator in C++
From the C++03 standard, section 2.5: 2.5 Alternative tokens Alternative token representations are provided for some operators and punctuators. In all respects of the language, each alternative token behaves the same, respectively, as its primary token, except for its spelling. The set of alternative tokens is defined in Table 2. Table 2—alternative tokens alternative primary … Read more
How to determine what C++ standard is the default for a C++ compiler?
What about compiling and executing the following trivial program ? #include <iostream> int main() { std::cout << __cplusplus << std::endl; } The value printed should say the version used: 199711 for C++98, 201103 for C++11 201402 for C++14 201703 for C++17 If you compile omitting the -std=c++xx flag, you should be able to detect the … Read more
expected unqualified-id before string constant
This is a simple problem. You just forgot the semi colon at the end of your header file. The compiler errors you get for missing the semi colon at the end of a class definition are very hard to relate to the actual problem – just get in the habit of checking that when you … Read more
constexpr initializing static member using static function
The Standard requires (section 9.4.2): A static data member of literal type can be declared in the class definition with the constexpr specifier; if so, its declaration shall specify a brace-or-equal-initializer in which every initializer-clause that is an assignment-expression is a constant expression. In your “second attempt” and the code in Ilya’s answer, the declaration … Read more
How to suppress specific warnings in g++
Unfortunately, this feature isn’t provided by g++. In VC++, you could use #pragma warning to disable some specific warnings. In gcc, the closest you can have is diagnostic pragmas, which let you enable/disable certain types of diagnostics for certain files or projects. Edit: GCC supports pushing/popping warnings since 4.6.4 (see changelog)
std::enable_if : parameter vs template parameter
Default template arguments are not part of the signature of a template (so both definitions try to define the same template twice). Their parameter types are part of the signature, however. So you can do template <class T> class check { public: template< class U = T, typename std::enable_if<std::is_same<U, int>::value, int>::type = 0> inline static … Read more