#define in c++

October 25, 2010 at 22:39:06
Specs: Windows XP
can anybody tell em that def mean

#define SwapByte4( ldata) \
(((ldata & 0x000000FF) << 24) | \
((ldata & 0x0000FF00) << 8) | \
((ldata & 0x00FF0000) >> 8) | \
((ldata & 0xFF000000) >> 24))
#endif

can anybody explain me.. in thsi regaerd i will be greatly thankfull to you ..
can any body explain me that & is used her as ailais here.. and what means by 0x000000FF and all other and its say as <24 or same in otehr case.. please help me in thsi regard and tell me what will this do? why its can be used.


See More: #define in c++

Report •


#1
October 26, 2010 at 17:58:02
Google:

network byte order

big endian

htonl


Report •

#2
October 27, 2010 at 13:44:10
It's a preprocessor macro, and this macro swaps the bytes of a 32-bit variable.
int someNumber = 0x11223344
std::cout << std::showbase << std::hex << SwapByte4(someNumber) << '\n'; 
//Displays: 0x44332211

How To Ask Questions The Smart Way


Report •
Related Solutions


Ask Question