2021年3月8日(月) 23:03 Christian Schoenebeck <qemu_...@crudebyte.com>: > > BTW, there is __nonnull supported by clang, e.g.: > > static void foo(void *__nonnull p) { > ... > } > > Maybe as an optionally defined macro (if supported by compiler) this could be > a useful tool for such intended nonnull designs, as it immediately emits > compiler errors. > > Best regards, > Christian Schoenebeck > >
GCC has nonnull attribute and clang accepts it too. However, it specifies argument indices, which is harder to understand and to maintain. __attribute__((nonnull(2))) void f(void *k, void *l); Regards, Akihiko Odaki