473,379 Members | 1,511 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

typedef and static

#include <stdio.h>

typedef void show(int,int);

int main()
{
static show myshow;
myshow(1,100);
//disp(1,5);
return 0;
}

static void myshow(x,y)
int x,y;
{
printf("%d %d\n",x,y);
}

Can anyone please explain the error ??
Jan 15 '08 #1
4 2885
In article <47***********@mindspring.com>,
pete <pf*****@mindspring.comwrote:
>The error was that functions can't have file scope.
C89 3.1.2.2 Linkages of Identifiers
[...]

If the declaration of a file scope identifier for an object
or a function contains the storage class specifier static,
the identifier has internal linkage.

--
"No one has the right to destroy another person's belief by
demanding empirical evidence." -- Ann Landers
Jan 15 '08 #2
Walter Roberson wrote:
>
In article <47***********@mindspring.com>,
pete <pf*****@mindspring.comwrote:
The error was that functions can't have file scope.

C89 3.1.2.2 Linkages of Identifiers
[...]

If the declaration of a file scope identifier for an object
or a function contains the storage class specifier static,
the identifier has internal linkage.
Please excuse me.
I misspelled "function scope" very badly,
when refering to this code:
typedef void show(int,int);

int main()
{
static show myshow;

--
pete
Jan 15 '08 #3
In article <47***********@mindspring.com>,
pete <pf*****@mindspring.comwrote:
>Walter Roberson wrote:
>>
In article <47***********@mindspring.com>,
pete <pf*****@mindspring.comwrote:
>The error was that functions can't have file scope.
>Please excuse me.
I misspelled "function scope" very badly,
when refering to this code:
typedef void show(int,int);

int main()
{
static show myshow;
Well of course functions cannot have function scope.

C89 3.1.2.1 Scope of Identifiers

An identifier is visible (i.e., can be used) only within a region
of program text called its cope. There are four kinds of scopes:
function, file, block, and function prototype. (A function prototype
is a declaration of a function that declares the types of its
parameters.)

A label name is the only kind of identifier that has function
scope. [...]

Every other identifier has scope determined by the placement of
its declaration (in a declarator or type specifier.) If the
declarator or type specifier that declares the identifier appears
outside of any block or list of parameters, the identifier has
file scope, which terminates at the end of the translation unit.
If the declarator or type specifiers that declares the identifier
appears inside a block or within the list of parameter declarations
in a function definition, the identifier has block scope, which
terminates at the } that closes the associated block. [...]

--
"Any sufficiently advanced bug is indistinguishable from a feature."
-- Rich Kulawiec
Jan 15 '08 #4
Walter Roberson wrote:
>
In article <47***********@mindspring.com>,
pete <pf*****@mindspring.comwrote:
Walter Roberson wrote:
>
In article <47***********@mindspring.com>,
pete <pf*****@mindspring.comwrote:
The error was that functions can't have file scope.
Please excuse me.
I misspelled "function scope" very badly,
when refering to this code:
typedef void show(int,int);

int main()
{
static show myshow;

Well of course functions cannot have function scope.

C89 3.1.2.1 Scope of Identifiers
It seems that I blew it again.

How about this one?
N869
6.7.1 Storage-class specifiers
[#5] The declaration of an identifier for a function that
has block scope shall have no explicit storage-class
specifier other than extern.

--
pete
Jan 16 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Jacek Dziedzic | last post by:
Hello! I'm creating a class that has a static method which would compute a lookup table needed later by all members of the class. The problem is, the lookup table is composed of records and one...
3
by: Generic Usenet Account | last post by:
This is a two-part question. (1) I have implemented a "Datastructure Registry" template class. I am getting no compiler warnings with older compilers, but newer compilers are generating the...
7
by: Tony Johansson | last post by:
Hello Experts! I have the following Array template class see below. I execute these three statements statement 1: Array<int> x(5); statement 2: cin >>x; statement 3: Array<int>::element_type ...
5
by: Cancerbero | last post by:
Hi (first, excuse me for my bad english) As I know, the semantics for typedef is: typedef A B; I think this makes B a synonym of A, where A is an existing data type. Is that right? Based...
2
by: Mehta Shailendrakumar | last post by:
Hi all, Have alook at two different declarations below: typedef unsigned char uc; typedef void (*fptr) (void); The first declaration has a left part which is a C keyword: "unsigned char"...
6
by: Alex | last post by:
Hello people, I am getting errors from VS2003 when working with typedef'ed types. For example, assume that I have a type T, defined in a 3rd party include file based on some condition #if...
23
by: myth.drannon | last post by:
lets say I have a header file : struct AAAA { blabla..... }; typedef struct AAAA A; typedef struct BBB
15
by: Ian Bush | last post by:
Hi All, I'm a bit confused by the following which is causing one of our user's codes fail in compilation: typedef struct SctpDest_S; 1) Is this standard ? 2) If so ( or even if not so ! )...
5
by: tissyrose | last post by:
Hi All, I am porting a very large application from VC++ 6.0 to VS 2005. There are many issues I am facing. One of them is I am getting an error "cannot access private typedef declared in...
12
by: Googy | last post by:
Hi!! Can any one explain me the meaning of following notations clearly : 1. typedef char(*(*frpapfrc()))(); frpapfrc f; 2. typedef int (*(arr2d_ptr)()); arr2d_ptr p; 3. typedef int...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.