Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!think.com!mintaka!gnu!dstailey From: dstailey@gnu.ai.mit.edu (Doug Stailey) Newsgroups: comp.lang.c Subject: Re: Scope of 'static' variables Keywords: extern, static Message-ID: <1990Dec7.051955.2883@mintaka.lcs.mit.edu> Date: 7 Dec 90 05:19:55 GMT References: <7744.27500de8@jetson.uh.edu> <2175@tuvie> Sender: daemon@mintaka.lcs.mit.edu (Lucifer Maleficius) Organization: MIT Laboratory for Computer Science Lines: 30 In article <2175@tuvie> hp@vmars.tuwien.ac.at (Peter Holzer) writes: >elee6i5@jetson.uh.edu writes: > > >The static variables usually get names which cannot clash with >other variables (something like L0001 (or just >BeginDataSegmentOfThisModule + Offset), C external variables are >prefixed with an underscore), and are not exported to other >modules. So static variables are just like globals but no other >function knows its name, so it cannot be referenced (except >through a pointer). > >Turbo C does it this way, and all other compilers I know do it >similarly. >-- But what if you want to call a function returning a static from another source module? Say for instance, in main.c you have a function declared: static char *get_cmd(FILE *fp) and you want to call it from misc.c. You can't say extern static char *get_cmd(FILE *fp) since most compilers will respond with the "too many storage classes" error. If I declare it: extern char *get_cmd(FILE *fp) this gives a warning under GCC. I'm not sure whether it works with Turbo C. How should such a function be declared externally? -- disclaimer: This message is sold by weight, not volume. Contents may have settled during shipment. Brought to you by Super Global Mega Corp .com