i tried run method expint from cmath and got error, i used c++17, c++17 should support this method but it doesn't see it. C++ version Apple clang version 13.1.6 (clang-1316.0.21.2). which version should I use so that the expint method is available?
//#define __STDCPP_WANT_MATH_SPEC_FUNCS__ 1
//#define __STDCPP_MATH_SPEC_FUNCS__ 201003L
#include <cmath>
#include <iostream>
int main(int argc, const char * argv[]) {
std::cout << "Hello, World!\n";
std::expint(10.4);
return 0;
}
expint docs one more expint docs
error
c++ configs
It may be a compatibility issue with the updated MacOS version or even the M1 (if you have it) chipset. With just the info on the application, it is still undeterminable what the root cause may be.
Related
I'm trying to get Matplotlib wrapper to work on wxDevC++
The code
#include <cstdlib>
#include <iostream>
#include "matplotlib-cpp/matplotlibcpp.h"
#include <vector>
namespace plt=matplotlibcpp;
using namespace std;
int main(int argc, char *argv[])
{
std::vector<double> y={1,3,2,4};
plt::plot(y);
plt::savefig("minimal.pdf");
cout << "Press the enter key to continue ...";
cin.get();
return EXIT_SUCCESS;
}
I use Win 7, I have python 27 and Python 38. It keeps telling me that there is no Python.h file. I've no idea how to fix this.
You have to set the include path for Pathon.h in your build configuration and you have to use at least C++11.
You can set the C++ standard in GCC and compatible compilers with the compiler option -std=c++11 or in older versions with -std=c++0x. For the GNU variants you can use -std=gnu++11 resp. -std=gnu++0x.
I am trying to do some very fast conversions in C++ and charconv seems the way to go since it uses a very low level logic. The problem is that when I try to include this header and then call, say, std::to_chars(...), neither the header is found nor std has a 'to_chars' member. I updated and reinstalled gcc but this problem is still there. Now I have seen some threads that say that I should update somehow libc++17 but they are not very specific about what I should do, as things are a bit different for MacOS.
Some code to illustrate the library and it's use:
#include <iostream>
#include <typeinfo>
#include <charconv> //error: 'charconv' file not found
struct to_chars_result{
char *str;
std::errc err;
};
int main(int argc, const char * argv[]) {
std::string str("12Test");
auto result = std::to_chars(str.data(), str.data()+str.size(), 12345); //No
//member named 'to_chars' in namespace 'std'.
return 0;
}
As for gcc -v command output:
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin14.4.0/5.1.0/lto-
wrapper
Ziel: x86_64-apple-darwin14.4.0
Konfiguriert mit: ../gcc-5.1.0/configure --enable-languages=c++,fortran
Thread-Modell: posix
gcc-Version 5.1.0 (GCC)
Any help appreciated!
gcc 5.1 was released on April 22, 2015.
The paper that added to_chars to the C++17 standard was written in 2016.
Why do you expect that gcc5 will have implemented it?
[ Later: That was the paper that added the <charconv> header, too ]
I'm using stl containers in my project and I discovered a weird error that I can't explain. Let's consider the following code:
#include <iostream>
#include <vector>
int main(int argc, char** argv)
{
std::vector<bool> vec;
vec.resize(5, false);
std::cout << vec.at(0);
}
This outputs 0 as expected, but if I run a memory check with drmemory it discovers an uninitialized read. Can anybody help in understanding this behaviour?
Platform: win32 ;
Compiler: mingw32 - gcc 4.7.2 ;
Drmemory 1.6.0 - build 2
std::vector<bool> is a bizarre little thing, using bit twiddling to achieve its goals. I'd be content in this instance to suggest that what you're seeing is just a red herring.
That being said, you might be better off with some other container, because this template specialisation is universally despised.
The regex_search function isn't quite behaving as expected.
#include <iostream>
#include <regex>
#include <string>
using namespace std;
int main()
{
string str = "Hello world";
const regex rx("Hello");
cout << regex_search(str.begin(), str.end(), rx) << endl;
return 0;
}
The output is
0
What's going on?
As pointed out in comments to the question, older implementations of the C++ standard libraries did not yet support all features in C++11. Of course, libc++ being an exception because it was originally built specifically for C++11.
According to this bug report support for <regex> in libstdc++ was only implemented for version 4.9 of GCC. You can check the current status on the libstdc++ status page.
One can confirm, that your example works with GCC 4.9 while still failing with GCC 4.8.
I installed Netbeans and as C++ compiler I installed cygwin. I made a simple project to test out my installation, this is the code:
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
cout << "test";
return 0;
}
This is the error message that it gives: http://pastebin.com/jRRh7MPi
I hope you guys can help me out.
You need to either explicitly link to C++ standard library, or compile using g++ instead of gcc.