Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

no matching function for call to ‘std::exception::exception(<brace-enclosed initializer list>)

My project builds on Windows (vc++17) and I am new to Linux builds so I am not sure what is going on.

I created CMakeLists files for my project (with a C++17 requirement), generated the makefile, and then I used make to try build it on Linux. The error is:

/home/julien/source/zipfs/zipfs/include/zipfs/zipfs_assert.h:30:70: error: no matching function for call to ‘std::exception::exception(<brace-enclosed initializer list>)’
   30 |   zipfs_usage_error_t(const char* message) : std::exception{ message } {}
      |                                                                      ^
In file included from /usr/include/c++/9/exception:38,
                 from /usr/include/c++/9/new:40,
                 from /usr/include/c++/9/ext/new_allocator.h:33,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/string:41,
                 from /home/julien/source/zipfs/zipfs/include/zipfs/zipfs_path_t.h:3,
                 from /home/julien/source/zipfs/zipfs/include/zipfs/zipfs_error_t.h:3,
                 from /home/julien/source/zipfs/zipfs/source/zipfs_error_t.cpp:1:

The incriminated code is:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

zipfs_usage_error_t(const char* message) : std::exception{ message } {}

I don’t see what is wrong with this; is it a c++ version mismatch ?

>Solution :

std::exception does not provide a constructor that accepts a const char* parameter.

If one exists on the Windows standard library you are using, it is a non-portable extension to the language.

There are many derived classes that could be used as your base class instead, which do support this constructor.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading