Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: bug raport - about way of linking in c |
| Date | 2012-09-29 14:11 -0700 |
| Organization | None to speak of |
| Message-ID | <ln7grcr0tf.fsf@nuthaus.mib.org> (permalink) |
| References | (9 earlier) <21c885d0-75e0-4ea2-9d10-8cf89aaf6bb2@googlegroups.com> <k44p50$9v9$1@dont-email.me> <8ac1dd27-52ae-4058-ae9d-0ca0531043bb@googlegroups.com> <k46kfd$nv7$1@dont-email.me> <9cd481fd-7af8-4b63-9889-4c3e3abe2162@googlegroups.com> |
fir <profesor.fir@gmail.com> writes:
[...]
> this is totally different topic, I was
> workin on that (I call it "shared statics")
> and invented such thing:
>
> void f()
> {
> static int x = 10;
> }
> void main()
> {
> f.x = 1; //you can reach static data
> //thru function name
> f();
> }
[...]
I'm not sure what that buys you. The point of declaring a static object
inside a function is that it restricts its visibility to the body of
that function (actually to the nearest enclosing block). If you want it
to be visible outside the function, you might as well write:
static int x = 10;
void f() {
/* ... */
}
int main(void) {
x = 1;
f();
}
If `x` is logically associated with `f`, you can give it a name that
indicates that.
Note that I've changed your `void main()` to `int main(void)`, which is
the correct definition of the main function. (An implementation is
permitted to support `void main()`, but it's essentially an extension,
whereas `int main(void)` is guaranteed to be supported by *any*
conforming hosted implementation.)
If you learned C from a book that told you to use `void main()`, I urge
you to find a better book; it's often an indication that the author
doesn't know the language very well. And no, `void main()` isn't merely
an obsolete form; the same standard that introduced the `void` keyword
also stated that the two valid forms of `main` are
int main(void) { /* ... */ }
and
int main(int argc, char *argv[]) { /* ... */ }
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar
bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-28 05:00 -0700
Re: bug raport - about way of linking in c James Kuyper <jameskuyper@verizon.net> - 2012-09-28 08:37 -0400
Re: bug raport - about way of linking in c Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-28 14:08 +0100
Re: bug raport - about way of linking in c James Kuyper <jameskuyper@verizon.net> - 2012-09-28 10:09 -0400
Re: bug raport - about way of linking in c "BartC" <bc@freeuk.com> - 2012-09-28 15:49 +0100
Re: bug raport - about way of linking in c Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-28 16:20 +0100
Re: bug raport - about way of linking in c Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-28 16:02 +0100
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-28 07:48 -0700
Re: bug raport - about way of linking in c "BartC" <bc@freeuk.com> - 2012-09-28 16:02 +0100
Re: bug raport - about way of linking in c Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-09-28 11:27 -0400
Re: bug raport - about way of linking in c "BartC" <bc@freeuk.com> - 2012-09-28 16:35 +0100
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-28 09:02 -0700
Re: bug raport - about way of linking in c Andrew Smallshaw <andrews@sdf.lonestar.org> - 2012-09-28 18:54 +0000
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-28 13:54 -0700
Re: bug raport - about way of linking in c Andrew Smallshaw <andrews@sdf.lonestar.org> - 2012-09-29 02:24 +0000
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-28 23:27 -0700
Re: bug raport - about way of linking in c Andrew Smallshaw <andrews@sdf.lonestar.org> - 2012-09-29 06:42 +0000
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-29 00:10 -0700
Re: bug raport - about way of linking in c Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-29 15:36 +0100
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-29 08:53 -0700
Re: bug raport - about way of linking in c Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-09-30 01:57 -0700
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-29 12:28 -0700
Re: bug raport - about way of linking in c Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-09-28 22:36 -0400
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-28 23:14 -0700
Re: bug raport - about way of linking in c Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-29 14:19 +0100
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-29 06:53 -0700
Re: bug raport - about way of linking in c Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-29 16:04 +0100
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-29 08:40 -0700
Re: bug raport - about way of linking in c Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-29 17:24 +0100
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-29 09:45 -0700
Re: bug raport - about way of linking in c Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-29 21:05 +0100
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-29 13:18 -0700
Re: bug raport - about way of linking in c Keith Thompson <kst-u@mib.org> - 2012-09-29 14:17 -0700
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-30 00:42 -0700
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-30 00:49 -0700
Re: bug raport - about way of linking in c Stephen Sprunk <stephen@sprunk.org> - 2012-09-30 03:22 -0500
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-30 01:37 -0700
Re: bug raport - about way of linking in c "BartC" <bc@freeuk.com> - 2012-09-30 11:01 +0100
Re: bug raport - about way of linking in c Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-09-30 02:06 -0700
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-29 10:23 -0700
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-29 11:03 -0700
Re: bug raport - about way of linking in c Keith Thompson <kst-u@mib.org> - 2012-09-29 14:30 -0700
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-30 00:25 -0700
Re: bug raport - about way of linking in c Stephen Sprunk <stephen@sprunk.org> - 2012-09-30 03:44 -0500
Re: bug raport - about way of linking in c "BartC" <bc@freeuk.com> - 2012-09-29 19:04 +0100
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-29 11:21 -0700
Re: bug raport - about way of linking in c Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-09-30 02:18 -0700
Re: bug raport - about way of linking in c Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-09-30 01:50 -0700
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-28 08:31 -0700
Re: bug raport - about way of linking in c "BartC" <bc@freeuk.com> - 2012-09-28 16:49 +0100
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-28 09:34 -0700
Re: bug raport - about way of linking in c Robert Wessel <robertwessel2@yahoo.com> - 2012-09-28 12:22 -0500
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-28 10:50 -0700
Re: bug raport - about way of linking in c "BartC" <bc@freeuk.com> - 2012-09-28 19:09 +0100
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-28 13:31 -0700
Re: bug raport - about way of linking in c Stephen Sprunk <stephen@sprunk.org> - 2012-09-28 16:37 -0500
Re: bug raport - about way of linking in c "BartC" <bc@freeuk.com> - 2012-09-29 11:54 +0100
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-29 05:13 -0700
Re: bug raport - about way of linking in c Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-29 15:42 +0100
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-29 08:12 -0700
Re: bug raport - about way of linking in c Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-29 17:19 +0100
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-29 10:04 -0700
Re: bug raport - about way of linking in c Robert Wessel <robertwessel2@yahoo.com> - 2012-09-29 13:03 -0500
Re: bug raport - about way of linking in c Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-29 20:59 +0100
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-29 13:55 -0700
Re: bug raport - about way of linking in c Keith Thompson <kst-u@mib.org> - 2012-09-29 15:34 -0700
Re: bug raport - about way of linking in c jacob navia <jacob@spamsink.net> - 2012-09-29 22:58 +0200
Re: bug raport - about way of linking in c Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-29 22:19 +0100
Re: bug raport - about way of linking in c "BartC" <bc@freeuk.com> - 2012-09-30 01:29 +0100
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-30 00:09 -0700
Re: bug raport - about way of linking in c Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-09-30 02:37 -0700
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-30 00:45 -0700
Re: bug raport - about way of linking in c Stephen Sprunk <stephen@sprunk.org> - 2012-09-29 20:30 -0500
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-29 23:55 -0700
Re: bug raport - about way of linking in c Stephen Sprunk <stephen@sprunk.org> - 2012-09-30 04:14 -0500
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-29 06:16 -0700
Re: bug raport - about way of linking in c Keith Thompson <kst-u@mib.org> - 2012-09-29 14:11 -0700
Re: bug raport - about way of linking in c Barry Schwarz <schwarzb@dqel.com> - 2012-09-29 14:28 -0700
Re: bug raport - about way of linking in c Keith Thompson <kst-u@mib.org> - 2012-09-29 15:38 -0700
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-30 04:10 -0700
Re: bug raport - about way of linking in c Keith Thompson <kst-u@mib.org> - 2012-09-30 04:20 -0700
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-30 04:48 -0700
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-30 05:33 -0700
Re: bug raport - about way of linking in c Stephen Sprunk <stephen@sprunk.org> - 2012-09-30 13:03 -0500
Re: bug raport - about way of linking in c Kaz Kylheku <kaz@kylheku.com> - 2012-10-01 21:48 +0000
Re: bug raport - about way of linking in c Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-09-30 02:30 -0700
Re: bug raport - about way of linking in c Robert Wessel <robertwessel2@yahoo.com> - 2012-09-28 17:19 -0500
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-28 23:46 -0700
Re: bug raport - about way of linking in c Stephen Sprunk <stephen@sprunk.org> - 2012-09-29 02:38 -0500
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-29 00:58 -0700
Re: bug raport - about way of linking in c Greg Martin <greg@softsprocket.com> - 2012-09-29 17:42 -0700
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-30 01:06 -0700
Re: bug raport - about way of linking in c Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-30 13:35 +0100
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-30 06:04 -0700
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-30 06:25 -0700
Re: bug raport - about way of linking in c Greg Martin <greg@softsprocket.com> - 2012-09-30 07:44 -0700
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-30 08:57 -0700
Re: bug raport - about way of linking in c Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-30 19:18 +0100
Re: bug raport - about way of linking in c Kaz Kylheku <kaz@kylheku.com> - 2012-10-01 21:49 +0000
Re: bug raport - about way of linking in c Thomas Richter <thor@math.tu-berlin.de> - 2012-09-30 18:35 +0200
Re: bug raport - about way of linking in c Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-30 19:32 +0100
Re: bug raport - about way of linking in c Stephen Sprunk <stephen@sprunk.org> - 2012-09-29 23:48 -0500
Re: bug raport - about way of linking in c Stephen Sprunk <stephen@sprunk.org> - 2012-10-02 08:05 -0500
Re: bug raport - about way of linking in c Kaz Kylheku <kaz@kylheku.com> - 2012-10-02 17:52 +0000
Re: bug raport - about way of linking in c "BartC" <bc@freeuk.com> - 2012-10-03 17:10 +0100
Re: bug raport - about way of linking in c Greg Martin <greg@softsprocket.com> - 2012-10-03 09:43 -0700
Re: bug raport - about way of linking in c Les Cargill <lcargill99@comcast.com> - 2012-10-03 12:58 -0500
Re: bug raport - about way of linking in c Stephen Sprunk <stephen@sprunk.org> - 2012-10-03 18:53 -0500
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-10-03 11:12 -0700
Re: bug raport - about way of linking in c Greg Martin <greg@softsprocket.com> - 2012-10-03 12:06 -0700
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-10-03 12:43 -0700
Re: bug raport - about way of linking in c Keith Thompson <kst-u@mib.org> - 2012-10-03 14:07 -0700
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-10-03 15:05 -0700
Re: bug raport - about way of linking in c Ian Collins <ian-news@hotmail.com> - 2012-10-04 11:23 +1300
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-10-04 00:06 -0700
Re: bug raport - about way of linking in c Ian Collins <ian-news@hotmail.com> - 2012-10-04 20:41 +1300
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-10-04 01:13 -0700
Re: bug raport - about way of linking in c Ian Collins <ian-news@hotmail.com> - 2012-10-04 21:24 +1300
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-10-04 01:38 -0700
Re: bug raport - about way of linking in c Ian Collins <ian-news@hotmail.com> - 2012-10-04 21:54 +1300
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-10-04 02:17 -0700
Re: bug raport - about way of linking in c Kaz Kylheku <kaz@kylheku.com> - 2012-10-03 22:35 +0000
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-10-03 15:42 -0700
Re: bug raport - about way of linking in c Stephen Sprunk <stephen@sprunk.org> - 2012-10-03 18:42 -0500
Re: bug raport - about way of linking in c Kaz Kylheku <kaz@kylheku.com> - 2012-10-04 01:31 +0000
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-10-04 02:54 -0700
Re: bug raport - about way of linking in c Keith Thompson <kst-u@mib.org> - 2012-10-03 15:55 -0700
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-10-03 15:19 -0700
Re: bug raport - about way of linking in c Keith Thompson <kst-u@mib.org> - 2012-10-03 15:59 -0700
Re: bug raport - about way of linking in c Jens Gustedt <jens.gustedt@loria.fr> - 2012-10-04 13:43 +0200
Re: bug raport - about way of linking in c gazelle@shell.xmission.com (Kenny McCormack) - 2012-10-04 13:33 +0000
Re: bug raport - about way of linking in c Keith Thompson <kst-u@mib.org> - 2012-10-04 12:47 -0700
Re: bug raport - about way of linking in c Jens Gustedt <jens.gustedt@loria.fr> - 2012-10-05 10:02 +0200
Re: bug raport - about way of linking in c Stephen Sprunk <stephen@sprunk.org> - 2012-10-03 18:57 -0500
Re: bug raport - about way of linking in c Lowell Gilbert <lgusenet@be-well.ilk.org> - 2012-10-03 20:37 -0400
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-10-03 23:53 -0700
Re: bug raport - about way of linking in c Lowell Gilbert <lgusenet@be-well.ilk.org> - 2012-10-03 20:30 -0400
Re: bug raport - about way of linking in c Kaz Kylheku <kaz@kylheku.com> - 2012-10-02 17:50 +0000
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-28 11:00 -0700
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-28 09:49 -0700
Re: bug raport - about way of linking in c Stephen Sprunk <stephen@sprunk.org> - 2012-09-28 13:37 -0500
Re: bug raport - about way of linking in c fir <profesor.fir@gmail.com> - 2012-09-28 11:51 -0700
Re: bug raport - about way of linking in c Stephen Sprunk <stephen@sprunk.org> - 2012-09-28 16:37 -0500
Re: bug raport - about way of linking in c Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-09-28 09:30 -0400
Re: bug raport - about way of linking in c Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-09-28 09:37 -0400
Re: bug raport - about way of linking in c Keith Thompson <kst-u@mib.org> - 2012-09-28 12:10 -0700
Re: bug raport - about way of linking in c Kaz Kylheku <kaz@kylheku.com> - 2012-09-28 18:49 +0000
csiph-web