summaryrefslogtreecommitdiffstats
path: root/generic/tk.h
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-06-15 20:41:14 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-06-15 20:41:14 (GMT)
commit3bf66eee9133ac628425b0b83043f65da1f6f8ac (patch)
tree19c0a06f718fda6bb89d0718f2e80031ffd5ac56 /generic/tk.h
parent408f37c9f38c74cfc41595ebeaedcc830f25d845 (diff)
downloadtk-3bf66eee9133ac628425b0b83043f65da1f6f8ac.zip
tk-3bf66eee9133ac628425b0b83043f65da1f6f8ac.tar.gz
tk-3bf66eee9133ac628425b0b83043f65da1f6f8ac.tar.bz2
Define offsetof() macro for (very rare) platforms which don't have it. Don't punish developers for using offsetof() in extensions, forgetting that ...
Diffstat (limited to 'generic/tk.h')
-rw-r--r--generic/tk.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/generic/tk.h b/generic/tk.h
index bf43b41..2a3d602 100644
--- a/generic/tk.h
+++ b/generic/tk.h
@@ -250,10 +250,10 @@ typedef struct Tk_ObjCustomOption {
* Computes number of bytes from beginning of structure to a given field.
*/
-#ifdef offsetof
#define Tk_Offset(type, field) ((int) offsetof(type, field))
-#else
-#define Tk_Offset(type, field) ((int) ((char *) &((type *) 0)->field))
+/* Workaround for platforms missing offsetof(), e.g. VC++ 6.0 */
+#ifndef offsetof
+# define offsetof(type, field) ((size_t) ((char *) &((type *) 0)->field))
#endif
/*