0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-10-10 00:25:06 -04:00

nasm_assert(): try to run at compile time if possible

Try to make nasm_assert() do a static assert if the argument can be
evaluated at compile time by any particular compiler. We also provide
nasm_try_static_assert() which will assert a compile-time expression
if and only if we can determine we have a constant at compile time
*and* we know that the compiler has a way to handle it.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin (Intel)
2018-12-14 14:21:16 -08:00
parent c3c6cea838
commit b7f24e7715
5 changed files with 71 additions and 21 deletions

View File

@@ -654,7 +654,7 @@ static uint16_t write_symbolinfo_properties(struct coff_Section *sect,
else if (win32)
section_write16(sect, 0x0006); /* machine */
else
nasm_assert(!"neither win32 nor win64 are set!");
nasm_panic("neither win32 nor win64 are set!");
section_write16(sect, 0); /* verFEMajor */
section_write16(sect, 0); /* verFEMinor */
section_write16(sect, 0); /* verFEBuild */
@@ -711,7 +711,7 @@ static uint16_t write_symbolinfo_symbols(struct coff_Section *sect)
section_write8(sect, 0); /* FLAG */
break;
default:
nasm_assert(!"unknown symbol type");
nasm_panic("unknown symbol type");
}
section_wbytes(sect, sym->name, strlen(sym->name) + 1);