mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-16 10:20:30 +00:00
Use predefined __offsetof__ builtin function when compiling C++ sources.
This commit is contained in:
parent
83eb8428e2
commit
c5faf12094
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=146941
@ -307,7 +307,14 @@
|
||||
* We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
|
||||
* require it.
|
||||
*/
|
||||
#ifndef __cplusplus
|
||||
#define __offsetof(type, field) ((size_t)(&((type *)0)->field))
|
||||
#else
|
||||
#define __offsetof(type, field) \
|
||||
(__offsetof__ (reinterpret_cast <size_t> \
|
||||
(&reinterpret_cast <const volatile char &> \
|
||||
(static_cast<type *> (0)->field))))
|
||||
#endif
|
||||
#define __rangeof(type, start, end) \
|
||||
(__offsetof(type, end) - __offsetof(type, start))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user