79671605

Date: 2025-06-19 06:14:56
Score: 1.5
Natty:
Report link

Consider this: Why should it be a redefinition? One must be able to define types that can be processed by functions in multiple translation units (e.g. .c files), true? typedef is a means to do just that. Don't fight it. :-) ...

By your same logic, then why isn't your function prototype a redefinition? Because it not a definition of an instance, it's a description. The typedef is also a description and not a definition.

For example, the move function itself (not the prototype) is a definition, and the compiler will generate a code block in the code segment for it. But the compiler won't generate any data in a data segment or (for local declaration) create a data block on the stack for a typedef alone.

If you duplicate the typedef or the prototype in the same translation unit (e.g. dup in the same .h or in the .h and .c as you tested for the typedef) that's a name/symbol redefinition error but not a redefinition of a data block or code block (i.e. instance).

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Coder