Are prototypes required for all functions in C89, C90 or C99?

前端 未结 6 1108
死守一世寂寞
死守一世寂寞 2020-11-22 16:55

To be truly standards-compliant, must all functions in C (except for main) have a prototype, even if they are only used after their definition in the same translation unit?<

6条回答
  •  无人及你
    2020-11-22 17:07

    To the best of my knowledge (in ANSI C89/ISO C90), no. I am unsure about C99; however, I would expect the same.

    Personal Note: I only write function prototypes when...

    1. I need to (when A() calls B() and B() calls A()), or
    2. I am exporting the function; otherwise, it feels superfluous.

提交回复
热议问题