0

I would like to use itoa in my String library for conversions. Is it safe to #undefine Strict ANSI macro so that itoa() becomes declared?

I mean the function works after undefining the macro. But I am worried I may be affecting more important aspects of the stdlib.h header.

  • 1
    You should not be using `` in C++, use `` instead. But `itoa()` is not a standard function to begin with. You should use a standard function like `std::to_string()` (C++11 and later) or `std::sprintf()` instead. – Remy Lebeau Aug 21 '18 at 22:46
  • Thanks for the help. But std to string is not compatible on every compiler, namely the mingw32 bit shipped with code blocks that I have been using from the get go. I want to create a library that everybody's compiler can make use of. It would help if I was sure that undefining that macro wasn't a bigger hazard. –  Aug 21 '18 at 23:43
  • You still shouldn't be using `itoa()` if you are worried about compiler compatibility. `sprintf()` into a `char[]` buffer would be more compatible. In any case, see [How can I add C++11 support to Code::Blocks compiler?](https://stackoverflow.com/questions/18174988/) – Remy Lebeau Aug 21 '18 at 23:47

0 Answers0