Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#Actualultramailman

Posted 06 April 2013 - 03:33 PM

gcc allows the use of unions for type punning. So maybe something like this?
 
(untested):
 
union tmp{
    int_t i;
    generic_list_t n;
} pun = {.n = *n};
printf("%d\n", pun.i.x);

 
edit:
Sorry, that was wrong. What if you cast n to void*, then cast that to int_t* ?

#4ultramailman

Posted 06 April 2013 - 03:30 PM

gcc allows the use of unions for type punning. So maybe something like this?
 
(untested):
 
union tmp{
    int_t i;
    generic_list_t n;
} pun = {.n = n};
printf("%d\n", pun.i.x);

 
edit:
Sorry, that was wrong. How about cast to void*, then cast to int_t* ?

#3ultramailman

Posted 06 April 2013 - 03:30 PM

gcc allows the use of unions for type punning. So maybe something like this?
 
(untested):
 
[s]union tmp{
    int_t i;
    generic_list_t n;
} pun = {.n = n};
printf("%d\n", pun.i.x);[/s]
 
edit:
Sorry, that was wrong. How about cast to void*, then cast to int_t* ?

#2ultramailman

Posted 06 April 2013 - 03:29 PM

gcc allows the use of unions for type punning. So maybe something like this?

 

(untested):

 

union tmp{
    int_t i;
    generic_list_t n;
} pun = {.n = n};
printf("%d\n", pun.i.x);

 

edit:

Sorry, that was wrong. How about cast to void*, then cast to int_t* ?


#1ultramailman

Posted 06 April 2013 - 03:27 PM

gcc allows the use of unions for type punning. So maybe something like this?

 

(untested):

union tmp{
    int_t i;
    generic_list_t n;
} pun = {.n = n};
printf("%d\n", pun.i.x);

PARTNERS