Re: creating a new integer type in C (incompatible with other types)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Vincent Lefevre:

> With GCC, in C, is they a way to create a new integer type,
> incompatible with other types?
>
> For instance, a new integer type that would have the same size
> as long int, but that would be incompatible with it. On a 64-bit
> platform, one could use long long int, but if one wants to create
> 3 or more types similar to long int, one would need some other
> method.
>
> The main goal would be to improve the robustness of the code
> by detecting programming errors at compile time, without making
> testing much complex to achieve this goal.

If you don't need to do arithmetic on the integer and it's small, the
usual way to do this is to cast it to a struct pointer with a unique tag
name.  This is how Windows added type safety to their handles many years
ago.

Thanks,
Florian




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux