Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: ‘std::chars_format’ has not been declared

Tags:

c++

A minimal part of my code is as follows:

#include <charconv>
#include <string_view>
#include <cmath>

int main() {

    return 0;
}

double strparse(std::string_view s, int field, int a, int b) {
    double candidates[3];
    auto format = std::chars_format::fixed;
    return 0;
}

However, compiling it under the command:

g++ -std=c++17 bob.cpp

Using g++ 9.2.1

returns:

bob.cpp: In function ‘double strparse(std::string_view, int, int, int)’:
bob.cpp:12:24: error: ‘std::chars_format’ has not been declared
   12 |     auto format = std::chars_format::fixed;
      |                        ^~~~~~~~~~~~

I'm not sure why this isn't compiling - can someone help?

Live demo

like image 932
user438383 Avatar asked Sep 15 '25 16:09

user438383


1 Answers

The reason it wouldn't compile is because there is only partial GCC support for std::chars_format::fixed.

like image 62
user438383 Avatar answered Sep 18 '25 06:09

user438383