Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatter Compilation Error #8750

Open
petrasvestartas opened this issue Feb 24, 2025 · 7 comments
Open

Formatter Compilation Error #8750

petrasvestartas opened this issue Feb 24, 2025 · 7 comments

Comments

@petrasvestartas
Copy link

petrasvestartas commented Feb 24, 2025

Formatter is not fully supported for C++20.

I am using MacBook Pro with Intel Chip that has Clang 14.
CMakeLists: https://github.com/petrasvestartas/wood/tree/main/cmake

Windows and Mac M1 have no problems compiling recent cgal but on this machine I get errors stated below.

Is there any CMake flag to disable formatter?

/Users/petras/brg/2_code/wood_nano/src/wood/cmake/build/install/cgal/include/CGAL/IO/io.h:1005:8: error: explicit specialization of undeclared template struct 'formatter'
struct formatter<CGAL::Output_rep<T, F>, CharT> : public std::formatter<std::basic_string<CharT>>
       ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/petras/brg/2_code/wood_nano/src/wood/cmake/build/install/cgal/include/CGAL/IO/io.h:1005:63: error: too few template arguments for class template 'formatter'
struct formatter<CGAL::Output_rep<T, F>, CharT> : public std::formatter<std::basic_string<CharT>>
                                                              ^
/Users/petras/brg/2_code/wood_nano/src/wood/cmake/build/install/cgal/include/CGAL/IO/io.h:1005:8: note: template is declared here
struct formatter<CGAL::Output_rep<T, F>, CharT> : public std::formatter<std::basic_string<CharT>>
       ^
/Users/petras/brg/2_code/wood_nano/src/wood/cmake/build/install/cgal/include/CGAL/IO/io.h:1007:29: error: no template named 'basic_format_parse_context' in namespace 'std'
  constexpr auto parse(std::basic_format_parse_context<CharT>& ctx)
                       ~~~~~^
/Users/petras/brg/2_code/wood_nano/src/wood/cmake/build/install/cgal/include/CGAL/IO/io.h:1015:18: error: no member named 'format_error' in namespace 'std'
      throw std::format_error("formatter for CGAL::Output_rep only support precision, like `{:.6}`");
            ~~~~~^
/Users/petras/brg/2_code/wood_nano/src/wood/cmake/build/install/cgal/include/CGAL/IO/io.h:1018:18: error: no member named 'format_error' in namespace 'std'
      throw std::format_error("Missing precision");
            ~~~~~^
/Users/petras/brg/2_code/wood_nano/src/wood/cmake/build/install/cgal/include/CGAL/IO/io.h:1020:18: error: no member named 'format_error' in namespace 'std'
      throw std::format_error("Invalid value for precision");
            ~~~~~^
/Users/petras/brg/2_code/wood_nano/src/wood/cmake/build/install/cgal/include/CGAL/IO/io.h:1036:17: error: too few template arguments for class template 'formatter'
    return std::formatter<std::basic_string<CharT>>::format(ss.str(), ctx);
                ^
/Users/petras/brg/2_code/wood_nano/src/wood/cmake/build/install/cgal/include/CGAL/IO/io.h:1005:8: note: template is declared here
struct formatter<CGAL::Output_rep<T, F>, CharT> : public std::formatter<std::basic_string<CharT>>
@sloriot
Copy link
Member

sloriot commented Feb 24, 2025

formatter is hidden behind the macro CGAL_CAN_USE_CXX20_FORMAT.

in config.h we have:

#if __cpp_lib_format >= 201907L
#  define CGAL_CAN_USE_CXX20_FORMAT 1
#endif

The test plaform cezanne is also an intel chip with AppleClang 14.0.0.14000029, and it does not have the issue.
Could you try commenting the define in CGAL/config.h (in Installation package) just to make sure it would fix the issue?

@petrasvestartas
Copy link
Author

In which folder I could find the config.h?

Image

@sloriot
Copy link
Member

sloriot commented Feb 24, 2025

include/CGAL/config.h

@petrasvestartas
Copy link
Author

petrasvestartas commented Feb 24, 2025

compiles after commenting out source code!

how to undefine this flag?

I tried cmakelist no effect:
add_definitions(-DCGAL_CAN_USE_CXX20_FORMAT=0)

I tried in main stdafx define this, no effect:

#undef CGAL_CAN_USE_CXX20_FORMAT
#define CGAL_CAN_USE_CXX20_FORMAT 0

@sloriot
Copy link
Member

sloriot commented Feb 25, 2025

Could you try modifying in config.h:

#if __cpp_lib_format >= 201907L
#  define CGAL_CAN_USE_CXX20_FORMAT 1
#endif

into

#if __cpp_lib_format >= 201907L && __has_include(<format>)
#  define CGAL_CAN_USE_CXX20_FORMAT 1
#endif

@afabri
Copy link
Member

afabri commented Mar 20, 2025

@petrasvestartas ping

@petrasvestartas
Copy link
Author

Very sorry, I will try again and let you know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants