[c++] Trigraph elimination

In C++, trigraphs are sequences of three characters that represent a single character. They were introduced to facilitate the input of certain characters on keyboards that lacked specific keys. However, they have been deemed redundant and error-prone, and their use is generally discouraged.

To eliminate trigraphs from your C++ code, you can use the appropriate compiler flag. For example, with the GNU Compiler Collection (GCC), you can use the -Wtrigraphs option to enable warnings about trigraphs and the -trigraphs option to enable their actual processing during compilation. The -trigraphs option can also be used to disable trigraph translation by specifying -trigraphs=no or -trigraphs=off.

By eliminating trigraphs from your code, you can avoid potential confusion and improve portability and maintainability.

For example, to compile a C++ program without trigraph translation using GCC, you can use the following command:

g++ -trigraphs=no -o output_file input_file.cpp

It is important to note that trigraphs have been removed from the latest C++ language standards, such as C++11 and later, so modern C++ codebases are less likely to encounter them.

By eliminating trigraphs from your code, you can improve its clarity and avoid potential issues related to trigraph interpretation in different environments.

References: