tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: macro expansion and types in <sys/types.h>
Hi,
On Fri, 05 Sep 2014 13:31:43 +0900, Brook Milligan <brook%nmsu.edu@localhost>
wrote:
I am building a package (samtools if anyone cares) that tries to define some
functions with c preprocessor macro expansions. In doing so it uses type names
(e.g., uint16_t) as both part of the function name as well as one of the types
within the function definition. However, in some but not all places the macro
expansion leads to extra underscores being prepended, i.e., uint16_t is
sometimes expanded as __uint16_t.
This is clearly a result of lines like the following in <sys/types.h>:
#ifndef uint16_t
typedef __uint16_t uint16_t;
#define uint16_t __uint16_t
#endif
It's also in <stdint.h>.
I feel it is bad idea to define it in both sys/types.h and stdint.h, and use
"uint16_t"
as a multiple definition guard name.
The problem is that the extra underscores that are added to the function names
do not match function calls elsewhere without them.
Here is a much simplified example. Running the following through gcc -E
#include <sys/types.h>
#define M0(x) void name_##x() { }
#define M1(x, y) void name_##x(y) { }
#define M2(x) M1(x,x)
M0(uint16_t)
M1(uint16_t,uint16_t)
M2(uint16_t)
yields the following (omitting all the stuff from sys/types.h):
void name_uint16_t() { }
void name_uint16_t(__uint16_t) { }
void name___uint16_t(__uint16_t) { }
I would appreciate some input from the c preprocessor wizards among you
regarding how to fix this problem.
Thanks for your help.
I don't know your situation well, but I've added following patches for the
issue:
devel/gobject-introspection/patches/patch-aa
lang/jamvm/patches/patch-src_interp_engine_interp.h
--
OBATA Akio / obata%lins.jp@localhost
Home |
Main Index |
Thread Index |
Old Index