-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,732
  • 12
  • 43
  • 60

1 Answers1

2
#if __cplusplus < 201703L
#error "C++17 or later is required!"
#endif
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770