It would be possible at runtime, yes. Perhaps you can use...
if (sizeof(a) != sizeof(b)) abort();
...type of macro.
It's runtime, but it's better than nothing.
(C++ can do it compile time.)
Type: Posts; User: Elysia
It would be possible at runtime, yes. Perhaps you can use...
if (sizeof(a) != sizeof(b)) abort();
...type of macro.
It's runtime, but it's better than nothing.
(C++ can do it compile time.)
Indeed. It's potent stuff.
Psuedo code, but...
Something along the lines of:
int main()
{
char mychar;
int myint;
char* c = safe_cast<char>(mychar); // Compiles
c = safe_cast<char>(myint); // Won't...
I don't think this sort of thing can be done in C, or at least not easily.
However, it can be done easily in C++.