troubleshooting Question

C macro not working in release mode visual studio

Avatar of srimallikarthik
srimallikarthikFlag for India asked on
CProgrammingMicrosoft Legacy OS
23 Comments1 Solution640 ViewsLast Modified:
Experts,

I am using the attached code snippet macros in our code for swapping bytes.
Problems i observed are:
1)when i give 8 byte value to SWAP_8BYTES(x) MACRO it is crashing. This is happening only for Release build in visual studio. Swap works fine for Debug build.

Is this because of any memory related issues? Please comment.

SWAP MACROS are:

#define SWAP_2BYTES(x)            ((((x)&0xFF00)>>8) | (((x)&0x00FF)<<8))
#define SWAP_4BYTES(x)            ( (SWAP_2BYTES( ((x)&0xFFFF0000)>>16) ) | ( (SWAP_2BYTES((x)&0x0000FFFF) )<<16) )
#define SWAP_8BYTES(x)            ( (SWAP_4BYTES( ((x)&0xFFFFFFFF00000000)>>32) ) | ( (SWAP_4BYTES((x)&0x00000000FFFFFFFF) )<<32) )


#define SWAP_2BYTES(x)		((((x)&0xFF00)>>8) | (((x)&0x00FF)<<8))
#define SWAP_4BYTES(x)		( (SWAP_2BYTES( ((x)&0xFFFF0000)>>16) ) | ( (SWAP_2BYTES((x)&0x0000FFFF) )<<16) )
#define SWAP_8BYTES(x)		( (SWAP_4BYTES( ((x)&0xFFFFFFFF00000000)>>32) ) | ( (SWAP_4BYTES((x)&0x00000000FFFFFFFF) )<<32) )
ASKER CERTIFIED SOLUTION
Zoppo

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 23 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 23 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros