Does ansi C place a limit on the number of external variables in a program?

后端 未结 3 407
刺人心
刺人心 2021-01-24 22:19

By external variable I mean a variable declared with the extern modifier (and defined elsewhere in the program).

I\'ve been told of this limitation, and couldn\

相关标签:
3条回答
  • 2021-01-24 22:25

    My understanding is that the language does not impose a maximum limitation. Compilers and platforms would impose a limit.

    Compilers may restict the quantity due to the memory they want to devote to tracking and translating these.

    The platform always has limited space for variables.

    0 讨论(0)
  • 2021-01-24 22:35

    Yes, there is a minimal limit that every compiler should support.

    In this case, every compiler should be able to support at least 4095 external identifiers in one translation unit (but most compilers probably support much more).

    0 讨论(0)
  • 2021-01-24 22:38

    The C99 standard specifies several translation limits (5.2.4.1). One of those is :

    4095 external identifiers in one translation unit

    The C89 standard specifies this limit (2.2.4.1) :

    511 external identifiers in one translation unit

    Note that these are minimum limits for conforming implementations, not absolute limits.

    0 讨论(0)
提交回复
热议问题