Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-02-23 05:50:12 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-02-23 05:50:12 +0300
commitc26fa67bcd051e55960dadbcd5a6ee4fd1d0fb4a (patch)
treebd487177978b767f360eca8afd428de55b8562ef /source/blender/blenlib/BLI_utildefines.h
parent765b842f9520843183bf0a3cdcd071f152bbbf9e (diff)
BLI_utildefines: add pointer offset macro
Handy since it keeps the type of the original.
Diffstat (limited to 'source/blender/blenlib/BLI_utildefines.h')
-rw-r--r--source/blender/blenlib/BLI_utildefines.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index de9133261fc..c7e26ce4320 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -481,6 +481,14 @@ extern "C" {
/* reusable ELEM macro */
#define ARRAY_SET_ITEMS(...) { VA_NARGS_CALL_OVERLOAD(_VA_ARRAY_SET_ITEMS, __VA_ARGS__); } (void)0
+#if defined(__GNUC__) || defined(__clang__)
+#define POINTER_OFFSET(v, ofs) \
+ ((typeof(v))((char *)(v) + ofs))
+#else
+#define POINTER_OFFSET(v, ofs) \
+ ((void *)((char *)(v) + ofs))
+#endif
+
/* Like offsetof(typeof(), member), for non-gcc compilers */
#define OFFSETOF_STRUCT(_struct, _member) \
((((char *)&((_struct)->_member)) - ((char *)(_struct))) + sizeof((_struct)->_member))