c++g++gtk3c++-modules

gtk with std=c++23 create 'is_constant_evaluated' error


Using g++ 15.1 and gtk3 (or also gtkmm with the needed changes) with this code

  #include <gtk/gtk.h>
  #include <iostream>
  int main() {
      std:: cout<< "bonjour" << std::endl;
  }

All is well. But if I make this change;

  #include <gtk/gtk.h>
  import std;
  int main() {
      std:: cout<< "bonjour" << std::endl;
  }

I get the error message:

error: conflicting language linkage for imported declaration 'constexpr bool std::__is_constant_evaluated()'
__is_constant_evaluated() _GLIBCXX_NOEXCEPT

How can I fix this ?


Solution

  • I was using Ubuntu 20.04 with g++ updated to g++15.1 (compiled from source)

    I changed to Ubuntu 25.04 and g++15.0 (from ubuntu's ppa)

    I checked a c++config.h file where _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED is defined now there are test for more recent version of c++ which seem to modify it depending on latest version of c++.

    So basically, everything must be very recent to work.