Search code examples
c++c++11stlport

STLPort using C++11


I'm trying to migrate my office code from C++ to C++11 and we make heavy use of STLPorts.

There's a compiler macro (http://www.stlport.org/doc/configure.html) - _STLP_LONG_LONG, which is used in our code and works fine in C++.

However, in C++ 11, this is not defined.

#if defined (_STLP_LONG_LONG)
// Doesn't come here

How can I fix this? I tried searching on the internet but the resources are very limited.

Edit: Here's the code

# if defined (_STLP_MSVC) || defined (__BORLANDC__) || defined (__ICL)
# define ULL(x) x##Ui64
typedef unsigned _STLP_LONG_LONG uint64;
# elif defined (_STLP_LONG_LONG) /// <---- Here
typedef unsigned _STLP_LONG_LONG uint64;
# define ULL(x) x##ULL
# elif defined(__MRC__) || defined(__SC__)              //*TY 02/25/2000 - added support for MPW compilers
# include "uint64.h"            //*TY 03/25/2000 - added 64bit math type definition
# else
#  error "there should be some long long type on the system!"
#  define NUMERIC_NO_64 1
# endif

As far as I can understand, the code is trying to find a long long type for the given platform. In case of pre C++11 on linux , g++ goes to the pointed line. But when I execute g++ -std=c++11 ..., g++ skips this line and goes to error "there should be song long long type on the system!"


Solution

  • It appears that STLPorts doesn't support C++11.

    If your code requires C++11, then you don't need to use _STLP_LONG_LONG at all, since long long is standard.

    If your code needs to work in older C++ as well, then you can define your own macro that works with C++11 as one would expect:

    #if __cplusplus >= 201103L
        #define MY_LONG_LONG long long
    #elif defined(_STLP_LONG_LONG)
        #define MY_LONG_LONG _STLP_LONG_LONG
    #endif
    

    Of course, if your code has to work in pre-C++11 standard, then you may also need to handle the situation where the compiler doesn't provide the long long-language extension i.e. use #ifdef MY_LONG_LONG to check whether you can use it.

    EDIT: For your definition, you should probably use std::int64_t instead of long long if you need a type that is 64 bits wide, as long long can technically be wider than 64 bits.