Re:Checked C: Making C Safer by Extension
by ainar-g on Sunday September 09, 2018 @05:25AM
(#17945098)
Re. syntax. I don't understand, why can't they just make _Ptr an attribute like _Atomic, and provide a header <stdchecked.h>. That is,
#include <stdchecked.h>
void read_next(int *b, int idx, checked int *out) {
int tmp = *(b+idx);
*out = tmp;
}Ok, we've squeezed in an 'r'.
It’s good to see people attempting this, though. I would think chances are good Microsoft will use it internally, and that already would be a win. Also, it’s a clang/LLVM extension. That makes it easier for third parties to start using it.
On the other hand, their choice to use Ptr<T> for familiarity with C++ requires users who want to keep their code compatible with C compilers that don’t support this a bit harder (it will require wrapping that in some macro, say _ptrTo(T)). That isn’t ideal for adoption in open source programs.