Open
Description
Currently, when the rewriter inserts a Checked C keyword, it always uses the true keyword (e.g., _Ptr
). The Checked C specification recommends using the nicer-looking stdchecked.h
aliases (e.g., ptr
) whenever possible, i.e., whenever there are no existing identifiers conflicting with them (except in the case of a header that might be included by files that don't use stdchecked.h
, even if the header itself uses no conflicting identifiers). 3C should support this.
How to decide whether to use the aliases?
- A command-line flag.
- See whether the file contains
#include <stdchecked.h>
. - See whether the alias is correctly defined at the location where we want to insert the keyword. This will handle cases where a programmer does
#include <stdchecked.h>
and then#undef
s one conflicting alias while retaining the ability to use the others. One hacky way to achieve this without deep integration with the preprocessor would be for 3C to insert a line like this between every pair of successive input lines before preprocessing.
// stdchecked aliases test: (ptr) (array_ptr) (nt_array_ptr) (checked) [...]
Then, to decide whether we can safely use an alias on a given line, we look at whether its expansion on the previous line is what we want. 🙂
As discussed with Mike, this cosmetic issue is low priority now, but it may become higher priority in the future: cosmetic issues can be important to the user experience and user perception of 3C.