Visual C++ doesn't have strtoll(): use _strtoi64() instead

jwatte's picture

When building code you port from Linux (or other GCC based systems) to Visual Studio, you may run into the Microsoft standard C library not containing a definition for strtoll(), which converts from a C string to a long long, 64-bit integer value.

error C3861: 'strtoll': identifier not found

The first few hits on Google didn't exactly help figure out what the deal was, but reading MSDN shows the problem: strtol() is implemented, but strtoll() simply isn't.

However, Microsoft provides another function, called _strtoi64(), which does the same thing, and has exactly the same signature (char const *, char **, int), so a simple define macro will fix the problem.

At the top of the file using strtoll(), you can add this macro. Or, if you have a common header file, you can add it there. Or, if you're using autoconf, try building a macro to emit it into config.h, I guess :-)

#if defined(_MSC_VER)
#define strtoll _strtoi64