Skip to content

3C should have a way to use stdchecked.h aliases #404

Open
@mattmccutchen-cci

Description

@mattmccutchen-cci

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?

  1. A command-line flag.
  2. See whether the file contains #include <stdchecked.h>.
  3. 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 #undefs 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions