| | |
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
-7
#2 27 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 27 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 |
* adobe ansi api array arrays bash binarysearch calculate centimeter char cm convert copyanyfile copypdffile createcopyoffile createprocess() csyntax directory dynamic fflush file floatingpointvalidation fork forloop frequency getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling gtkwinlinux hardware highest homework i/o ide inches initialization intmain() iso km linked linkedlist linux linuxsegmentationfault list logical_drives loopinsideloop. lowest match matrix microsoft motherboard mqqueue mysql oddnumber odf open opendocumentformat opensource openwebfoundation pattern pdf performance pointer pointers posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition reversing scanf scheduling segmentationfault send shape single socketprogramming stack standard strchr string suggestions test unix urboc user variable voidmain() whythiscodecausesegmentationfault win32api windows.h






