2

I'm encountering this error while compiling some old VC++ 6.0 source code.

error C2632: 'long' followed by 'long' is illegal

There's a part of the code that declares a long long int variable which caused the error. Does anybody know how I can fix this error compiling it in VC++ 6.0? I've searched around and I've read that this data type is not yet supported in this version. However, this is an old code and I'm sure this was compiled in VC++ 6.0.

jasonline
  • 8,646
  • 19
  • 59
  • 80

3 Answers3

6

AFAIK Visual C++ 6.0 only supports __int64 (Microsoft's own type definition for 64-bit integers). long long is a standard type from C99, which 6.0 doesn't support.

Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412
1

I don't think VC6 supports the long long data type, but if you have the necessary typedefs already you could replace "long long" with "__int64" with a minimum of hassle.

ChrisV
  • 3,363
  • 16
  • 19
0

error C2632: 'long' followed by 'long' is illegal

Microsoft finally added support for long long and unsigned long long at Visual Studio 2013.

Also see Which C99 features are available in the MS Visual Studio compiler?.


Does anybody know how I can fix this error compiling it in VC++ 6.0?

The problem also exists in the early .Net compilers, too. You have to use macros and Microsoft extensions to do it in a portable manner.

Here's how Crypto++ handles it (the project still supports old compilers to avoid forcing users to make unwanted choices):

#if defined(_MSC_VER) || defined(__BORLANDC__)
    typedef unsigned __int64 word64;
    #define W64LIT(x) x##ui64
#else
    typedef unsigned long long word64;
    #define W64LIT(x) x##ULL
#endif

You would then use it like so. It will work for VC++ 5.0/6.0, Visual Studio .Net, Visual Studio 2010, GCC, Clang, Intel, etc.

word64 x = W64LIT(0x0000000000000001);
Community
  • 1
  • 1
jww
  • 97,681
  • 90
  • 411
  • 885
  • They actually had `long long` since at least VS2010, not 2013. According to the MSDN, the earliest version to have it was actually VS 2005, where it was listed as equivalent to `__int64`. It _might_ have been in VS.NET 2003, but the archived documentation contradicts itself. [Here](https://msdn.microsoft.com/en-ca/library/cc953fe1(v=vs.71).aspx), chart 1 doesn't mention it, but chart 2 does. – Justin Time - Reinstate Monica Jun 22 '16 at 17:19