``++typedef++``s are a convenient way of encapsulating complex types in simpler names. However, ``++typedef++``ing a pointer type is problematic because when ``++const++`` is applied to the defined type, it makes the pointer constant, not the pointed-to value. Even when that is what's intended, maintainers may misunderstand.


== Noncompliant Code Example

----
struct book {
  int isbn;
  int publishYear;
};
typedef book;
typedef *pBook;  // Noncompliant

void mangleBook(const pBook pb) {
  pb->isbn = 4;  // this is legal; its the pointer, not the book that's const
  pb->publishYear=1900;
}
----


== Exceptions

Function pointers are ignored by this rule.


== See

* https://www.securecoding.cert.org/confluence/x/14At[CERT, DCL05-C.] - Use typedefs of non-pointer types only


ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]
