tech-userlevel archive

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

Re: Definitions of types also as macros



In article <20180908230813.GA22777%SDF.ORG@localhost>,  <coypu%sdf.org@localhost> wrote:
>we do this in stdint.h and some other headers:
>
>#ifndef uint32_t
>typedef __uint32_t      uint32_t;
>#define uint32_t        __uint32_t
>#endif
>
>
>Real-world examples:
>https://github.com/neovim/neovim/blob/94841e5eaebc3f2fb556056dd676afff21ff5d23/src/nvim/map.h#L12
>https://github.com/NetBSD/pkgsrc/blob/trunk/www/firefox/patches/patch-servo_components_style_build__gecko.rs
>
>And now I ran into:
>https://cgit.freedesktop.org/mesa/mesa/tree/src/compiler/builtin_type_macros.h#n42
>
>Proposal: let's not define the macros?
>I don't know if there are long running consequences for it.

The problem is that these are defined in multiple headers and
typedef redefinition with the same type is a c11 feature, so the
define protects against that. Of course one can use a different
macro and this was done before, but this has other disadvantages.

christos



Home | Main Index | Thread Index | Old Index