Thread: Casting to pointer from integer

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered Abuser
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    591

    Casting to pointer from integer

    I'm porting my code over to 64-bit and get the "casting to pointer from integer of different size" warning from:
    Code:
    (void *)(int)foo
    I can understand it warning about a loss of information (casting down), but casting up isn't dangerous and the compiler should no more complain than had I done (long long)(int). Anyways I suppose that's compiler philosophy. What I need to know is how do I shut it up without resorting to #ifdef's?
    This does not work:
    Code:
    (void *) (sizeof(void *) == sizeof(long long) ? (long long)foo : foo)
    only other alternative I can think of is -Wno-int-to-pointer-cast
    Last edited by @nthony; 06-29-2010 at 02:11 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 04-04-2009, 03:45 AM
  2. Casting pointer to unsigned short
    By cks2k2 in forum C Programming
    Replies: 6
    Last Post: 03-25-2009, 05:33 AM
  3. memory issue
    By t014y in forum C Programming
    Replies: 2
    Last Post: 02-21-2009, 12:37 AM
  4. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  5. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM