Can we build PyTorch extensions for c++17?

Hi folks,

I’m trying to build an extension that uses another library that was developed using c++17.

For now I’m just including the header of that library and the build process is complaining a lot, I tried to compile it myself by changing ‘-std=c++11’ to ‘-std=c++17’ and the compilation went fine, however, I’m wondering if it’s possible to build extensions with c++17 and if it’s the case then how to use the torch.utils.cpp_extension module to configure the build?

1 Like

Did you find a solution for this? I am experiencing this issue too - I need some c++17 features but can’t figure out how to supply the -std=c++17 flag to the compiler. As far as I understand the BuildExtension only allows to supply additional compiler flags, but it does not allow me to change default compiler flags.

What I did was to pass extra compile args to use C++17, you can check my setup.py file here for an example. However, I stopped at the PoC level, and didn’t try to build anything realistic out of it.

1 Like

Thanks, very helpful to see your setup.py - it seems I should have implemented it slightly different. Using the flag as such does get me a bit further into compiling with c++17 but there are still some errors.