Thread: question regarding type long

  1. #16
    Registered User
    Join Date
    Jan 2006
    Location
    Berkeley, Ca
    Posts
    195
    Hmmm..... Oh sweet heavens. I think you're right. Okay. I need a few hours (or days) to let think sink into my thick skull.

  2. #17
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164
    Interesting... Same code:
    Code:
    #include <stdio.h>
    
    int main()
    {
            printf("size of int: %i\n", sizeof(int));
            printf("size of long: %i\n", sizeof(long));
            printf("size of long long: %i\n", sizeof(long long));
            printf("size of long long int: %i\n", sizeof(long long int));
    
            return 0;
    }
    Results from two compilers (emphasis mine):

    Compiler 1:
    size of int: 2
    size of long: 4
    size of long long: 4
    size of long long int: 4

    Compiler 2:
    Error E2176 x.c 7: Too many types in declaration in function main
    Error E2176 x.c 8: Too many types in declaration in function main
    *** 2 errors in Compile ***

    Not the results you got
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  3. #18
    Registered User
    Join Date
    Mar 2006
    Posts
    7
    Yea I didn't mean to provide some production code, just trying to demonstrate the concept. I'm running an i686 with the 2.6.15-gentoo-r1 linux kernel and compiled with gcc 3.4.5. Systems like mine will always get the same result, but may very on other systems.

  4. #19
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > "In addition; there are a number of qualifiers that can be applied to these basic data types. short and long apply to integers".
    I think what it's trying to say is that you can't have for example
    long char foo;
    short double bar;

    Whereas with qualifiers you can have
    volatile char foo;
    const double bar;

    long and short only apply to integers, not chars, floats, doubles or pointers.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inserting a swf file in a windows application
    By face_master in forum Windows Programming
    Replies: 12
    Last Post: 05-03-2009, 11:29 AM
  2. Can you check what is wrong with this code
    By Ron in forum C++ Programming
    Replies: 4
    Last Post: 08-01-2008, 10:59 PM
  3. Replies: 0
    Last Post: 03-20-2008, 07:59 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. need help
    By emperor in forum C Programming
    Replies: 1
    Last Post: 03-04-2002, 12:26 PM