Skip to content

Instantly share code, notes, and snippets.

@inequation
Created January 30, 2014 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inequation/8708932 to your computer and use it in GitHub Desktop.
Save inequation/8708932 to your computer and use it in GitHub Desktop.
Casting madness
// g++ test.cpp -o test -m32
#include <stdint.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
void *foo = (void *)0xF0000000;
int bar = 0;
int64_t x = reinterpret_cast<int32_t>(foo) | (static_cast<int64_t>(bar) << 32);
printf("x = %ld\n", x);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment