Created
October 7, 2025 04:49
-
-
Save BrynM/0253d220c5176c2de3ce725366df121e to your computer and use it in GitHub Desktop.
Swap Byte Macro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * This should work for ints too, but we only need bytes. Either way, both args | |
| * must be the same type for XOR to work properly. | |
| * https://dev.to/pauljlucas/a-generic-swap-macro-in-c-22me | |
| * https://www.hackerearth.com/practice/notes/swapping-without-a-temporary-variable-take-care/ | |
| * https://dev.to/pauljlucas/cc-preprocessor-macros-fh5 | |
| */ | |
| #define SWAP_BYTE(A, B) do { ( (A) ^= (B) ^= (A) ^= (B) ); } while (0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment