Naming convention when using STRUCT in C

There is no benefit in user code, it’s just ugly. In the second example, the HuffCode_ isn’t even necessary since the struct type is already named by the typedef.

The only places where this can be useful are:

  1. When StructName is already in use, StructName_ gives a different name (but you should really come up with a better name).
  2. Identifiers in the C standard library that are not defined by the standard shouldn’t conflict with user code identifiers. Therefore, C library writers use the _ prefix in the hopes that users will not use that. Unfortunately, some users do.
  3. In very old compilers, it may be useful to give the struct a different name than is used in the typedef. You need both the typedef and the other name if you’re building a linked structure (example).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)