problem in unsigned long long

Discussion in 'C Programming' started by vadivel.ks, Apr 9, 2007.

  1. vadivel.ks

    vadivel.ks Guest

    hi,
    My code having unsigned long long int64_t;
    like that.. compile error message is long followed by long is
    illegal,
    what is the reason for it?
     
    vadivel.ks, Apr 9, 2007
    #1
    1. Advertisements

  2. vadivel.ks

    Lew Pitcher Guest

    Probably, you are not using a C99-compliant compiler.

    Prior to C99, long long was not a standard data type, and instead was
    an extension that /some/ compilers provided. Apparently, your compiler
    is one that did not implement this non-standard (wrt pre-C99
    standards) data type.
     
    Lew Pitcher, Apr 9, 2007
    #2
    1. Advertisements

  3. vadivel.ks

    vadivel.ks Guest

    Thaks for immediate reply...

    how to convert unsigned long long int64_t for gcc
    compiler
     
    vadivel.ks, Apr 9, 2007
    #3
  4. GCC has supported "unsigned long long" for many years; if you're not using a
    version that understands it, you really need to upgrade.

    That makes me wonder, though, what the actual code you're trying to use
    looks like. Can you post a compilable example and the error messages you
    get?

    S
     
    Stephen Sprunk, Apr 9, 2007
    #4
  5. vadivel.ks

    David Mathog Guest

    What compiler flags are you using, which version of gcc, which platform?

    You may have specified some combination that prevents gcc from
    recognizing "long long" as a valid type. Make a tiny example program
    and try compiling it with

    gcc -std=c99 example example.c

    For any fairly recent gcc on most platforms that should handle long long
    types correctly.

    Regards,

    David Mathog
     
    David Mathog, Apr 9, 2007
    #5
  6. Current versions of gcc support unsigned long long and current versions
    of libraries supplied with gcc have the header <stdint.h> with int64_t
    defined there. If you upgrade to a current version of gcc and supplied
    libraries, remove the typedef for int64_t from your code and add
    #include <stdint.h> to the top of your code.

    Otherwise, if you continue to use a (very) old version of gcc without
    long long, then you have no type available for int64_t. You can, of
    course, lie and
    typedef unsigned long int64_t;
    but that is not recommended.

    It is possible that you are compiling with flags that disable
    recognition of long long. 'long long' is not in ISO C90, so compilation
    with -std=c89 or its equivalent -ansi _may_ disable recognition of long
    long. gcc will, unless told to treat warnings as errors, properly
    handle long long but emit warnings. You want to use -std=c99.

    If you are compiling without specifying the -std, your copy of gcc will
    compile a language very much like C, but not quite. The version of the
    nonstandard 'GNU C' language chosen will probably be -std=gnu89, which
    will generate diagnostics for long long. For posting to comp.lang.c,
    you always want to specify a version of standard C, -ansi or -std=c90
    for the old standard, -std=c99 for an attempt at conforming to the new
    standard. _Never_ post code for which GNU C is the language used, and
    since not specifying a standard is the same as -std=gnu89, that is to be
    avoided.
     
    Martin Ambuhl, Apr 9, 2007
    #6
  7. Your code is very likely to have something like

    typedef unsigned long long int64_t;

    Since your question is related to a specific compiler, you have to try
    a compiler specific newsgroup. You might want to try gnu.gcc.help GCC
    also has mailing lists which might be helpful.

    <OT>
    GCC version 3.2.2 (around four years old) supports unsigned long long.
    It complains only when invoked in c89 mode.
    </OT>

    Have a nice day,
    Pradeep
     
    R Pradeep Chandran, Apr 9, 2007
    #7
  8. Why? What's it supposed to mean? How is int64_t defined? Do you have
    That depends on the answers to the questions above.
     
    J. J. Farrell, Apr 9, 2007
    #8
  9. You have what?

    If you have a declaration

    unsigned long long int64_t;

    then you're declaring an object "in64_t" of type "unsigned long long".
    That's a bad idea, since "int64_t" is used in C99 as a type name, not
    an object name.

    Show us the *exact* code you're trying to compile.

    If you have <stdint.h>, then you should already have a typedef for
    "int64_t", and you don't need to declare it yourself. If your
    compiler, in whatever mode you're invoking it in, doesn't support type
    "unsigned long long", then you won't be able to use "unsigned long
    long" unless you use a different compiler, or the same compiler in a
    different mode.

    gcc comes with extensive documentation. Try "info gcc".
     
    Keith Thompson, Apr 9, 2007
    #9
  10. <OT>

    I think you mean either
    gcc -std=c99 example.c -o example
    or
    gcc -std=c99 -c example.c
    The latter doesn't attempt to invoke the linker to create an
    executable, but it will catch compile-time errors.
    </OT>
     
    Keith Thompson, Apr 9, 2007
    #10
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.