abi check: prefer nim constant to enable, document

This commit is contained in:
Jacek Sieka 2016-11-03 22:30:00 +08:00
commit fa86571448
3 changed files with 7 additions and 7 deletions

View file

@ -703,7 +703,7 @@ proc getTypeDescAux(m: BModule, typ: PType, check: var IntSet): Rope =
else: getTupleDesc(m, t, result, check) else: getTupleDesc(m, t, result, check)
if not isImportedType(t): if not isImportedType(t):
add(m.s[cfsTypes], recdesc) add(m.s[cfsTypes], recdesc)
elif tfIncompleteStruct notin t.flags: elif tfIncompleteStruct notin t.flags and isDefined("checkabi"):
addf(m.s[cfsTypeInfo], "NIM_CHECK_SIZE($1, $2);$n", [result, rope(getSize(t))]) addf(m.s[cfsTypeInfo], "NIM_CHECK_SIZE($1, $2);$n", [result, rope(getSize(t))])
of tySet: of tySet:
result = getTypeName(t.lastSon) & "Set" result = getTypeName(t.lastSon) & "Set"

View file

@ -258,6 +258,10 @@ Define Effect
``ssl`` Enables OpenSSL support for the sockets module. ``ssl`` Enables OpenSSL support for the sockets module.
``memProfiler`` Enables memory profiling for the native GC. ``memProfiler`` Enables memory profiling for the native GC.
``uClibc`` Use uClibc instead of libc. (Relevant for Unix-like OSes) ``uClibc`` Use uClibc instead of libc. (Relevant for Unix-like OSes)
``checkAbi`` When using types from C headers, add checks that compare
what's in the Nim file with what's in the C header
(requires a C compiler with _Static_assert support, like
any C11 compiler)
================== ========================================================= ================== =========================================================

View file

@ -460,10 +460,6 @@ typedef int Nim_and_C_compiler_disagree_on_target_architecture[sizeof(NI) == siz
# include <sys/types.h> # include <sys/types.h>
#endif #endif
/* Compile with -t:-DNIM_CHECK_ABI to enable */ /* Compile with -d:checkAbi and a sufficiently C11:ish compiler to enable */
#ifdef NIM_CHECK_ABI
#define NIM_CHECK_SIZE(typ, sz) \ #define NIM_CHECK_SIZE(typ, sz) \
_Static_assert(sizeof(typ) == sz, "Nim & C disagree on type size") _Static_assert(sizeof(typ) == sz, "Nim & C disagree on type size")
#else
# define NIM_CHECK_SIZE(typ, sz)
#endif