gcc 4.7 Give me error message - c++

I have Debian 6.04 , and the latest gcc version included is gcc 4.4 , and this version doesn't support C++11 , and i look for another version support C++11 ( some features not completely supported ) , so i follow this Page
I suggest to install it and My NetBeans IDE succeeded to find gcc 4.7 andlink it , but when i compile the code using a test by using std::unique_ptr i get this error message :
This file requires compiler and library support for the \
ISO C++ 2011 standard. This support is currently experimental, and must be \
enabled with the -std=c++11 or -std=gnu++11 compiler options.
i found the error source and her is :
bits/c++0x_warning.h
#ifndef _CXX0X_WARNING_H
#define _CXX0X_WARNING_H 1
#ifndef __GXX_EXPERIMENTAL_CXX0X__
#error This file requires compiler and library support for the \
ISO C++ 2011 standard. This support is currently experimental, and must be \
enabled with the -std=c++11 or -std=gnu++11 compiler options.
#endif
#endif

The error says it all. Trying adding -std=c++11 or -std=gnu++11 to the compiler options in your NetBeans IDE.
I've not used Netbeans but see this link where a snapshot of build variables is shown and that is where you need to add the compiler options.

Related

std::numbers has not been declared - GCC 11.2 on Windows

I have GCC 11.2.0 installed on my Windows 10 machine (from here: https://winlibs.com/). I have updated the environment variable Path to C:\MinGW\bin
gcc version 11.2.0 (MinGW-W64 x86_64-posix-seh, built by Brecht Sanders)
I'm using VSCode with the C/C++ extension configured to use the correct compiler path.
I want to use a C++20 feature which is
std::numbers::sqrt2
Still I get an error telling me it doesn't know std::numbers
[Running] cd "c:\Users\XX\XX\" && g++
main.cpp -o main && "c:\Users\XX\XX\"main
main.cpp: In function 'double sin_x_plus_cos_sqrt2_times_x(double)':
main.cpp:15:41: error: 'std::numbers' has not been declared
15 | return std::sin(x) + std::cos( std::numbers::sqrt2 * x );
|
I've added the header #include <numbers>
What am I missing ?
Default version of c++ standard for this version of gcc is C++17.
See this: https://godbolt.org/z/4Pjzd5r7s
Use
g++ main.cpp -o main -std=c++20
to force C++20
There is some support of C++20 in gcc, but it is simply to early to make it default standard.
What am I missing ?
In order to use C++20 features, you need to select the C++20 standard version.
Both gcc 10 & 11 require -std=c++20 on the command line for std::numbers to work. (Older versions than that don't support std::numbers at all)
https://gcc.gnu.org/projects/cxx-status.html#cxx20 shows progress on standards compliance. I would expect a standard to become default soon after all the details of the standard are met. As of Nov 2021, it seems they've got pretty much everything except some remaining details of the C++20 "modules" features.

C++20 in Qt Creator

I want to use std::source_location in Qt Creator, I've built the GCC 11.1 and checked it using g++ main.cpp -std=c++20 that it works. I've created a kit in Qt Creator to use this compiler and I was able to build it by adding:
QMAKE_CXXFLAGS += -std=c++2a
It works and I can even debug it without issues but Qt keeps saying that I have an error (which is not an error because the build passes):
error: no type named 'source_location' in namespace 'std'
Is there something I can do to fix this?
It's all about clang's static analysis. The gcc's (or strictly libstdc++'s) header <source_location> contains following guard:
#if __cplusplus > 201703L && __has_builtin(__builtin_source_location)
The guard doesn't allow clang to work as it doesn't support __builtin_source_location. Please follow the clang PR that fixes this issue.

Myo armband gestures in MATLAB (Unable to compile the .m or .mex file)

I need some help to make a myo-mex file to work. I don't know how to change the compiler options so that the mingw supports ISO c++ 2011. The github repository where the code is can be found here: https://github.com/mark-toma/MyoMex.
The error message Im getting look like the following:
Error using build_myo_mex (line 61)
In file included from C:/MATLAB/SupportPackages/R2015b/MW_MinGW_4_9/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/array:35:0,
from C:\MyoMex-master\MyoMex\myo_mex\myo_class.hpp:16,
from C:\MyoMex-master\MyoMex\myo_mex\myo_mex.cpp:14:
C:/MATLAB/SupportPackages/R2015b/MW_MinGW_4_9/lib/gcc/x86_64-w64- mingw32/4.9.2/include/c++/bits/c++0x_warning.h:32:2: error: #error This
file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled
with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
Im a bit clueless of this error, but I hope someone will be able to help since Im not the best at using MATLAB.
Its mentioned right in the error message
This support is currently experimental, and must be enabled with the
-std=c++11 or -std=gnu++11 compiler options.
Use:
-std=c++11 or -std=gnu++11

Getting _CXX0X_WARNING_H in XCode when I compile code with GCC 5.3

I use this Plugin in XCode for turning on GCC 5.3: https://github.com/hmazhar/xcode-gcc/blob/master/GCC%205.2.xcplugin/Contents/Resources/GCC%205.2.xcspec
I've replaced all 5.2 with 5.3 and have installed GCC 5.3 with brew on my OS X.
Then I changed Compiler for C/C++/Objective-C to my GCC 5.3 but when I try to compile C++ code I get following message. Where should I change settings?
#ifndef _CXX0X_WARNING_H
#define _CXX0X_WARNING_H 1
#if __cplusplus < 201103L
#error This file requires compiler and library support for the \
ISO C++ 2011 standard. This support is currently experimental, and must be \
enabled with the -std=c++11 or -std=gnu++11 compiler options.
#endif
#endif
Xcode 7.2, OS X El Captain 10.11.3, GCC 5.3.
Outdated:
- it doesn't work.
Following some articles to enabling GCC 4.5 I haven't done only this step:
2)In the project settings
delete “CLANG_CXX_LIBRARY" row
I don't know to remove it. I should empty value of this variable or should I remove it entirely? Can it be the root of my problem?

Compile with Intel 12.1.3 using gcc4.7 std library

I'm having the same problem described in this post except I'm using Intel version 12.1.3. (g++'s header <functional> is protected with #ifdef __GXX_EXPERIMENTAL_CXX0X__ which is not defined when icpc is used.)
Instead of using boost::functional, I wanted to install gcc4.7 and use it's std libraries.
In Ubuntu 11.10 I have gcc4.6.1 but I also installed gcc4.7 from the gcc-snapshot package.
Intel has the options -gcc-name, -gxx-name, and -cxxlib.
So originally I compiled with:
-std=c++0x -gcc-name=/usr/lib/gcc-snapshot/bin/gcc -gxx-name=/usr/lib/gcc-snapshot/bin/g++ -cxxlib=/usr/lib/gcc-snapshot/
but I get the error:
icpc: error #10282: file
'/usr/lib/gcc-snapshot/bin/usr/lib/gcc-snapshot/bin/g++' not found,
generated based on '-cxxlib=/usr/lib/gcc-snapshot/'
So then I compiled with:
-std=c++0x -gcc-name=./gcc -gxx-name=./g++ -cxxlib=/usr/lib/gcc-snapshot/.
But I still get the warnings and errors:
Warning #2928: the __GXX_EXPERIMENTAL_CXX0X__ macro is disabled when using GNU version 4.6 with the c++0x option
error: namespace "std" has no member "function"
The warning clearly says it's still using version 4.6. Does anybody know how to get Intel to use the correct libraries?
I've found that if you compile with gcc (or g++) with flags -v -Q you get a list of flags and defines. It might help you see what gcc does so maybe you can use the same -D/-U in icpc. also g++ -E will preprocess without compiling: you can get useful path information from that.