3 ms·
Nothing is stopping you from passing different -std=c++XY arguments to different compilation units in your codebase. I don't know about other compilers but obje
by plq 6y ago
Nothing is stopping you from passing different -std=c++XY arguments to different compilation units in your codebase. I don't know about other compilers but object files compiled with msvc, gcc and clang (the ones I happen to work with) using different -std values (starting with c++11) are compatible* and the respective teams working on these compilers reportedly make conscious efforts to make sure this remains the case.
CMake for instance makes this very easy with its set_properties() call.
* Of course there are caveats and corner cases. See eg. https://stackoverflow.com/questions/46746878/is-it-safe-to-link-c17-c14-and-c11-objects https://stackoverflow.com/questions/46746878/is-it-safe-to-l...
But these seem like they could easily be avoided in real-world use-cases.
- wscott 6y agoYes I can add new features to some files or I can compile with c++17 and link to an old C library. What I can't do is remove features or change the default calling conventions/ABI and still link with old code. If you declare in the interface and in the code that this is new code with new rules then this is possible. When you cross library boundaries the compiler adjusts. That is what rust allows and what C++ could do.