-1

How do I check during compilation that GCC (or any other compiler) has at least C++17 running? Can you give a minimal preprocessor snippet that emits an error if the version is below C++17?

I presume this can be built from __cplusplus and the #error directive.

shuhalo
  • 5,252
  • 7
  • 40
  • 56

1 Answers1

2
#if __cplusplus < 201703L
#error "C++17 or later is required!"
#endif
Remy Lebeau
  • 505,946
  • 29
  • 409
  • 696