CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 1999
    Posts
    123

    long long data type

    I am trying to compile third party c code in Visual C++ (10 years old).

    Long long data type is used extensively (thousands of times).

    Example: PrintLongInteger(void *,char *,long long);

    I get this error message: 'long' followed by 'long' is illegal

    What is the best way to solve this problem?

  2. #2
    Join Date
    Apr 1999
    Posts
    123

    Re: long long data type

    I tried:

    #define long long __int64

    and

    typedef __int64 long long

    Both produce compiler errors.

    Is there a way to replace "long long" with "__int64" in the code without resorting to brute force manual editing?

    BTW, I am using Visual C++ 6.0

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: long long data type

    How about using LARGE_INTEGER or int64?
    Victor Nijegorodov

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: long long data type

    Quote Originally Posted by Bob H View Post
    Is there a way to replace "long long" with "__int64" in the code without resorting to brute force manual editing?
    Did you try Menu -> Edit -> Replace...?
    Victor Nijegorodov

  5. #5
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: long long data type

    'long long' is a new style construct that isn't recognised by VC6.

    So no this code won't compile in VC6, and there's nothing to do other than actual replacing (either manually or with an automated 'find and replace') or swap to a more modern compiler.

    You can't #define this out since defined names can't have spaces.

    So... either use a newer compiler that supports the syntax. Or edit (replace) the actual code.
    Last edited by OReubens; December 6th, 2010 at 11:25 AM.

  6. #6
    Join Date
    Apr 1999
    Posts
    123

    Re: long long data type

    Thanks, I did the manual replace. With some other related changes, I got it to compile.

  7. #7
    Join Date
    Oct 2009
    Posts
    577

    Smile Re: long long data type

    Quote Originally Posted by Bob H View Post
    I tried:

    #define long long __int64

    and

    typedef __int64 long long

    Both produce compiler errors.

    Is there a way to replace "long long" with "__int64" in the code without resorting to brute force manual editing?

    BTW, I am using Visual C++ 6.0
    In order to have only one portable source code you might have a global header like

    Code:
    // portable.h
    #ifndef PORTABLE_H
    #define PORTABLE_H
    
    // check if MSVC compiler
    #ifdef _MSC_VER
    #define LongLong __int64
    #else
    #define LongLong long long
    #endif
    Then use LongLong everywhere instead of non-portable type.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured