Using standard version flags with GCC (GNU Compiler Collection) can help you specify which version of the C++ standard you want to use during compilation. This allows you to enforce compatibility with a specific standard, ensuring your code behaves consistently across different environments.
To use a standard version flag, you can include the -std=
option followed by the desired C++ standard. Here are some common versions:
-std=c++98
for C++98-std=c++11
for C++11-std=c++14
for C++14-std=c++17
for C++17-std=c++20
for C++20-std=c++2a
(or -std=c++20
) for features from C++20For example, to compile a file named example.cpp
using the C++14 standard, you would use the following command in your terminal:
g++ -std=c++14 example.cpp -o example
How do I avoid rehashing overhead with std::set in multithreaded code?
How do I find elements with custom comparators with std::set for embedded targets?
How do I erase elements while iterating with std::set for embedded targets?
How do I provide stable iteration order with std::unordered_map for large datasets?
How do I reserve capacity ahead of time with std::unordered_map for large datasets?
How do I erase elements while iterating with std::unordered_map in multithreaded code?
How do I provide stable iteration order with std::map for embedded targets?
How do I provide stable iteration order with std::map in multithreaded code?
How do I avoid rehashing overhead with std::map in performance-sensitive code?
How do I merge two containers efficiently with std::map for embedded targets?