Source-Changes-D archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: CVS commit: src/sys/sys
On Fri, 14 Mar 2014, Joerg Sonnenberger wrote:
Modified Files:
src/sys/sys: cdefs.h
Log Message:
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.
This is wrong, __INCLUDE_LEVEL__ does not exist unconditionally.
You could define a special token in each include file, and then use
that token if it is defined. You could also use __INCLUDE_LEVEL__ only
if it's defined. Something like this (untested):
/* in foo/bar.h: */
#ifndef _FOO_BAR_H
#define _FOO_BAR_H
#undef __HEADER_NAME_TOKEN
#define __HEADER_NAME_TOKEN _FOO_BAR_H
/* insert real content here */
#endif /* _FOO_BAR_H */
/* in sys/cdefs.h: */
#define __CTASSERT0(x, y, z1, z2, z3) __CTASSERT1(x, y, z1, z2, z3)
#define __CTASSERT1(x, y, z) \
typedef char y ## z1 ## z2 ## z3[/*CONSTCOND*/(x) ? 1 : -1] __unused
#if defined(__COUNTER__)
# define __CTASSERT(x) __CTASSERT0(x, __ctassert, __COUNTER__,,)
#else
# if defined(__INCLUDE_LEVEL__)
# define __tmp_z1 __INCLUDE_LEVEL__
# else
# define __tmp_z1 /* Empty */
# endif
# if defined(__HEADER_NAME_TOKEN)
# define __tmp_z2 __HEADER_NAME_TOKEN
# else
# define __tmp_z2 /* Empty */
# endif
# define __CTASSERT(x) _CTASSERT0(x, __ctassert, __tmp_z1, __tmp_z2, __LINE__)
# undef __tmp_z1
# undef __tmp_z2
#endif
--apb (Alan Barrett)
Home |
Main Index |
Thread Index |
Old Index