How to determine the version of the C++ standard used by the compiler?

By my knowledge there is no overall way to do this. If you look at the headers of cross platform/multiple compiler supporting libraries you’ll always find a lot of defines that use compiler specific constructs to determine such things: You probably will have to do such defines yourself for all compilers you use.

How to determine the version of the C++ standard used by the compiler?

By my knowledge there is no overall way to do this. If you look at the headers of cross platform/multiple compiler supporting libraries you’ll always find a lot of defines that use compiler specific constructs to determine such things: You probably will have to do such defines yourself for all compilers you use.

Is std::stoi actually safe to use?

Does std::stoi throw an error on the input “abcxyz”? Yes. I think your confusion may come from the fact that strtol never reports an error except on overflow. It can report that no conversion was performed, but this is never referred to as an error condition in the C standard. strtol is defined similarly by all three C standards, and I will spare … Read more

Is std::stoi actually safe to use?

Does std::stoi throw an error on the input “abcxyz”? Yes. I think your confusion may come from the fact that strtol never reports an error except on overflow. It can report that no conversion was performed, but this is never referred to as an error condition in the C standard. strtol is defined similarly by all three C standards, and I will spare … Read more

Is “argv[0] = name-of-executable” an accepted standard or just a common convention?

Guesswork (even educated guesswork) is fun but you really need to go to the standards documents to be sure. For example, ISO C11 states (my emphasis): If the value of argc is greater than zero, the string pointed to by argv[0] represents the program name; argv[0][0] shall be the null character if the program name is not available from the host environment. … Read more

Using ssize_t vs int

There’s no guarantee in the POSIX standard that sizeof(int) >= sizeof(ssize_t), nor the other way around. Typically ssize_t is larger than int, but the safe and portable option in C99 is to use intmax_t instead for the argument and the return value. The only guarantees you have wrt. the relationship between int and ssize_t are: int can store values of at least the range [-2^15 … … Read more