Warn if another typedef'd name of a type is used in an argument list

后端 未结 6 1497
天涯浪人
天涯浪人 2021-01-02 09:46

Consider a large project, where many types are typedef\'d, e.g.

typedef int age;
typedef int height;

and some functions gettin

6条回答
  •  生来不讨喜
    2021-01-02 10:18

    There is no built-in support for this in GCC.

    There is a feature request to add this, based on the Sparse nocast attribute. However, this hasn't been implemented. If you can use Sparse, though, you could do this by marking each typedef with __attribute__((nocast)).

    In C++ you can do this by making wrapper classes rather than typedefs, and then simply not defining implicit conversions for them.

提交回复
热议问题