Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

static in C

Name: Richard 2010-12-22 7:35

Hi. (:

I'm a C# programmer who recently had to write some C code. I found out that C has the static keywoard but C doesn't have classes so it can't do the same thing static does in C#. Please explain static in C to me.

Name: Anonymous 2010-12-22 7:39

Name: Anonymous 2010-12-22 8:36

Hi
why dont you read a book about the C programming language, just about anyone will do, they will all have an explanation of how the static keyword is used

Name: Anonymous 2010-12-22 8:40

>>1
Don't use Sepparsh

Name: Richard 2010-12-22 8:48

Hi again. (:

Why does one keyword mean two different things in to languages that are syntactically the same family?

Name: Anonymous 2010-12-22 8:51

>>5
syntactically the same family

Name: Anonymous 2010-12-22 9:25

Name: Anonymous 2010-12-22 9:26

Name: Anonymous 2010-12-22 9:30

Hi again,

Why does one keyword mean two different things in the Java and C++ languages when they are syntactically the same family?

Name: Anonymous 2010-12-22 9:35

((Java != C++) &&
 (Cpp != C) &&
 (C != Csharp) &&
 (Csharp != Java) &&
 (Java != C) &&
 (Csharp != Java))

Name: Anonymous 2010-12-22 9:35

>>10
s/C++/Cpp/

Name: Anonymous 2010-12-22 10:48

>>5
Because the designers of C++ had a goal of introducing as few new keyword as possible, to maintain as much compatibility with C code as possible (which includes not only compiling C code as C++ code with minor changes, but also easily calling C functions (which may happen to be named with a new keyword)).

The `static` keyword already means two different things in C: on the module level it means that the decorated object (a variable or a function) would not be exported, inside a function body it means that its value persists between invocations (as if it was declared outside the function, but not visible from anywhere other than this function).

C++ gave it a third meaning: in the class definition context it means that the decorated object belongs to a class and has class lifetime (which is a kind of similar to the second meaning, in a weird way).

Then C# got rid of the first two meanings, so there's no intersection between C and C# meanings.

Name: Anonymous 2010-12-22 12:33

>>10
(and (!= Java C++)
     (!=      Cpp C)
     (!=          C CSharp)
     (!= Java       Csharp)
     (!= Java     C))

Name: Anonymous 2010-12-22 13:24

>>13
You could save some ink by using or and =.

Name: Anonymous 2010-12-22 13:42

>>14
You can't expect a /prague/rider to know highschool logic.

Name: Anonymous 2010-12-22 14:17

>>12
You can think of both C meanings as "Make this symbol live at the global level, but define the it only for the current scope"

Name: Anonymous 2010-12-22 14:34

>>14
bitch tits you have

Name: >>12 2010-12-22 15:05

>>16
Thank you, I tried to find proper words but failed and decided not to mention anything about that connection, while you put it most concisely.

Name: Anonymous 2011-02-03 4:01

Name: Anonymous 2011-02-04 19:08

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List