Recently, I came to the conclusion that you need to have statements at the compilation stage in C ++ to make sure that the sizes of the two types are equal.
I found the following macro on the Internet (claimed to come from the Linux kernel):
#define X_ASSERT(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
which I used like this:
X_ASSERT(sizeof(Botan::byte) != sizeof(char));
I get interested - although this works, is there a cleaner way to do this? (obviously, there is more than one way, as it is) Are there advantages or disadvantages of certain methods?
source
share