diff options
author | Divay Prakash <divayprakash@users.noreply.github.com> | 2018-10-10 19:09:41 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-10 19:09:41 +0530 |
commit | 8ef6b4fc0cece273b84a87f2cdb8317edec2139a (patch) | |
tree | 61ff31ae5c23937b9af07fd62712a49f695c983f | |
parent | dfd9cd2285de4e39ebdfa49b0d86c9ce6a2afd39 (diff) | |
parent | 4311e3866710ed02cef29cd62d66c123b9300f14 (diff) |
Merge pull request #3275 from divayprakash/fix-c
Make description of static keyword stronger, closes #2848
-rw-r--r-- | c.html.markdown | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/c.html.markdown b/c.html.markdown index bf93dcf5..7975a1c2 100644 --- a/c.html.markdown +++ b/c.html.markdown @@ -605,6 +605,14 @@ static int j = 0; //other files using testFunc2() cannot access variable j void testFunc2() { extern int j; } +// The static keyword makes a variable inaccessible to code outside the +// compilation unit. (On almost all systems, a "compilation unit" is a .c +// file.) static can apply both to global (to the compilation unit) variables, +// functions, and function-local variables. When using static with +// function-local variables, the variable is effectively global and retains its +// value across function calls, but is only accessible within the function it +// is declared in. Additionally, static variables are initialized to 0 if not +// declared with some other starting value. //**You may also declare functions as static to make them private** /////////////////////////////////////// |