Internal static variables in C, would you use them?

后端 未结 13 1491
甜味超标
甜味超标 2020-12-07 19:09

In C you can have external static variables that are viewable every where in the file, while internal static variables are only visible in the function but is persistent

13条回答
  •  时光取名叫无心
    2020-12-07 20:05

    I think that people generally stay away from internal static variables. I know strtok() uses one, or something like it, and because of that is probably the most hated function in the C library.

    Other languages like C# don't even support it. I think the idea used to be that it was there to provide some semblance of encapsulation (if you can call it that) before the time of OO languages.

提交回复
热议问题