[ros-dev] gcc/msvc int64 suffix/LARGE_INTEGER portability macros

Gunnar Dalsnes hardon at online.no
Tue Feb 1 22:18:55 CET 2005


Suggested gcc/msvc portability macros:

#if defined(_MSC_VER)
 
   #define MK_INT64(a) (a)
   #define MK_UINT64(a) (a)
 
   __inline LARGE_INTEGER MK_LARGE_INTEGER(__int64 i)
   {
      LARGE_INTEGER li;
      li.QuadPart = i;
      return li;
   }
 
   #define LARGE_INTEGER_NULL MK_LARGE_INTEGER(0)

#elif defined (__GNUC__)
 
   #define MK_INT64(a) (a##LL)
   #define MK_UINT64(a) (a##ULL)
 
   #define MK_LARGE_INTEGER(a) ((LARGE_INTEGER)(LONGLONG)a)
 
   #define LARGE_INTEGER_NULL ((LARGE_INTEGER)(LONGLONG)0LL)
 
#else
   #error Unknown compiler for LARGE_INTEGER/int64 macros
#endif


example:

LARGE_INTEGER test1(LARGE_INTEGER arg)
{
 return MK_LARGE_INTEGER(arg.QuadPart+3);
}

LARGE_INTEGER test2()
{
 LARGE_INTEGER a = LARGE_INTEGER_NULL;
 a.QuadPart += test1(LARGE_INTEGER_NULL).QuadPart;
 a.QuadPart += MK_INT64(1152921504606846975);
 return LARGE_INTEGER_NULL;
}

What do you think?

Gunnar



More information about the Ros-dev mailing list