tech-userlevel archive

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

Definitions of types also as macros



we do this in stdint.h and some other headers:

#ifndef uint32_t
typedef __uint32_t      uint32_t;
#define uint32_t        __uint32_t
#endif


then, if a package does something like this:

#include <stdint.h>

#define function(name, type) int name##_##type() { return 3; }
#define useless_wrapper(name, type) function(name, type)

useless_wrapper(something, uint32_t)

int main() {
	return something_uint32_t();
}



It doesn't work, because we define something___uint32_t as a function.

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.


Home | Main Index | Thread Index | Old Index