| | |
32 bits/64 bits case
![]() |
•
•
Join Date: Oct 2009
Posts: 3
Reputation:
Solved Threads: 0
Hi All,
I have the application which will be support 32 bits and 64 bits
and below are the statement to handle 32bits/64bits data
and new_node->data
is void * new_node->data
for ( index = 0 ; index < items ;index++ ) {
if (data_size == SIZE_32 ) {
* ( ((int32_t*)(new_node->data)) + index) = (int32_t) index*2 ;
* ( ((int32_t*)(new_node-> data)) + index) = (int32_t) index*3
}
else {
* ( ((int64_t*)(new_node-> data)) + index) = (int64_t) index*4;
* ( ((int64_t*)(new_node-> data)) + index) = (int64_t) index*5;
}
}
Is there any better to handle this without the if/else statement (if ((data_size == SIZE_32 ) {
Thanks
J
I have the application which will be support 32 bits and 64 bits
and below are the statement to handle 32bits/64bits data
and new_node->data
is void * new_node->data
for ( index = 0 ; index < items ;index++ ) {
if (data_size == SIZE_32 ) {
* ( ((int32_t*)(new_node->data)) + index) = (int32_t) index*2 ;
* ( ((int32_t*)(new_node-> data)) + index) = (int32_t) index*3
}
else {
* ( ((int64_t*)(new_node-> data)) + index) = (int64_t) index*4;
* ( ((int64_t*)(new_node-> data)) + index) = (int64_t) index*5;
}
}
Is there any better to handle this without the if/else statement (if ((data_size == SIZE_32 ) {
Thanks
J
-5
#2 21 Days Ago
I would use a typedef
C Syntax (Toggle Plain Text)
#ifdef SIZE_32 typedef __int32 inttype; #else typedef __int64 inttype; #endif int main() { inttype a = 0; }
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
1
#3 21 Days Ago
if (data_size == SIZE_32 ) {
* ( ((int32_t*)(new_node->data)) + index) = (int32_t) index*2 ;
* ( ((int32_t*)(new_node-> data)) + index) = (int32_t) index*3;
}
else {
* ( ((int64_t*)(new_node-> data)) + index) = (int64_t) index*4;
* ( ((int64_t*)(new_node-> data)) + index) = (int64_t) index*5;
}* ( ((int32_t*)(new_node->data)) + index) = (int32_t) index*2 ; if in the next expression it gets changed right away? * ( ((int32_t*)(new_node-> data)) + index) = (int32_t) index*3; Same in the else ![]() |
Similar Threads
- Much Ado About Bits (Computer Science)
- Bits in a byte (C++)
- Video games ?bits? (IT Professionals' Lounge)
- OpenGL (Game Development)
- Begginer Question (C)
- Open Gl Programing Error (help)... (Game Development)
- Null Pointer (C++)
- Exercise using: unsigned int datecode(int year, int month, int day); (C++)
- what is the difference between regular and 64 bit edition (Windows NT / 2000 / XP)
Other Threads in the C Forum
- Previous Thread: UART problem!
- Next Thread: Print table of a number entered by user
| Thread Tools | Search this Thread |
#include * adobe ansi array arrays asterisks binarysearch centimeter changingto char character cm convert copyimagefile cprogramme creafecopyofanytypeoffileinc createprocess() database dynamic execv feet fgets file floatingpointvalidation fork function getlogicaldrivestrin givemetehcodez global grade gtkwinlinux hacking histogram inches include incrementoperators infiniteloop input interest intmain() iso kernel keyboard kilometer km license linked linkedlist linux locate looping lowest matrix meter microsoft number oddnumber open opendocumentformat openwebfoundation owf pattern pdf performance pointer posix power probleminc process program programming radix recursion recv recvblocked research reversing segmentationfault sequential single socket socketprograming socketprogramming standard strchr string suggestions systemcall test threads turboc unix urboc user variable voidmain() wab whythiscodecausesegmentationfault windowsapi






