473,396 Members | 2,036 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,396 software developers and data experts.

Pointer to extern char?

While reading the page on "Reading C Declarations"
<http://www.ericgiguere.com/articles/reading-c-declarations.html>
(recommended by Mr. Heathfield at
<http://www.cpax.org.uk/prg/portable/c/resources.php>), I came across
the following declaration:

extern char *const (*goop( char *b ))( int, long );

which is explained as:

declare goop as function returning pointer to function returning const
pointer to extern char

How can there be a pointer to extern char? Doesn't extern here mean
that the function has external linkage?

Dec 9 '06 #1
3 6360
"coder" <pl***********@gmail.comwrote in message
news:11**********************@80g2000cwy.googlegro ups.com...
<snip>
>
extern char *const (*goop( char *b ))( int, long );

which is explained as:

declare goop as function returning pointer to function returning const
pointer to extern char

How can there be a pointer to extern char? Doesn't extern here mean
that the function has external linkage?

extern there should refer to goop, because 'char *const (__cdecl *)(int,long)'
is a return type and a return type cannot be extern. Makes no sense really.

--
"It is easy in the world to live after the world's oppinion; it easy in solitude
to live after our own; but the great man is he who in the midst of the crowd
keeps with perfect sweetness the independence of solitude."
Ralph Waldo Emerson, Self-reliance 1841
http://pinpoint.wordpress.com/

Dec 9 '06 #2
In article <11**********************@80g2000cwy.googlegroups. com>
coder <pl***********@gmail.comwrote:
>While reading the page on "Reading C Declarations"
<http://www.ericgiguere.com/articles/reading-c-declarations.html>
(recommended by Mr. Heathfield at
<http://www.cpax.org.uk/prg/portable/c/resources.php>), I came across
the following declaration:

extern char *const (*goop( char *b ))( int, long );

which is explained as:

declare goop as function returning pointer to function returning const
pointer to extern char

How can there be a pointer to extern char? Doesn't extern here mean
that the function has external linkage?
Yes, the explanation is just wrong.

"extern" is one of the four (well, five, sort-of) storage-class
specifiers (the complete list is: auto, extern, register, static,
typedef; typedef is an sc-specifier just for syntax purposes).
The presence of an sc-specifier modifies identifiers, not types:

static int a, *b, c(foo);

makes "a", "b", and "c" all static.

The actual modification performed by an sc-specifier is contextual,
so it can be difficult to describe. For instance, "static" affects
linkage when a declaration occurs at file scope, but affects
storage-duration when a declaration occurs at block scope. The
"extern" keyword usually gives identifiers external linkage, but
not always.

In the example above, "goop" has external linkage (just as you have
said) unless an earlier declaration is in scope that already gave
it internal linkage. That is, given:

static int foo(void);
extern int foo(void);

both declarations specify internal linkage -- the "extern" here
means "static" (!). Delete the first line, however, and the second
line suddenly means "external" (!). Omitting "extern" gives the
identifier external linkage, so:

static int foo(void);
int foo(void);

is an error (although no diagnostic is required) -- adding the
"extern" fixes the code so that both declarations of foo() give it
internal linkage.

(Nobody ever said C was consistent. :-) )
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Dec 9 '06 #3
Chris Torek wrote:
In article <11**********************@80g2000cwy.googlegroups. com>
coder <pl***********@gmail.comwrote:
<snip>

Yes, the explanation is just wrong.
<...>
Thanks for the clarification, Chris.

Dec 10 '06 #4

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

Similar topics

12
by: ur8x | last post by:
Why does this declaration give undefined result: file1: extern char * p; file2: char p; Let's assume p has been initialized, now accessing p...
5
by: Danilo Kempf | last post by:
Folks, maybe one of you could be of help with this question: I've got a relatively portable application which I'm extending with a plugin interface. While portability (from a C perspective) is...
6
by: Angel | last post by:
I'm exporting (with DllImport) a C-style function with this syntax: int z9indqry (4_PARM *parm); 4_PARM is a structure declared in a proprietary header file that cannot be included in my...
2
by: Tom | last post by:
Hi newsgroup, I have read a lot af articles about marshalling in C#, but none of them could help me to solve the following problem: There is a C-DLL with the following header-file: ++++++++...
4
by: Leo | last post by:
Hello, I have a C dll with a method signature of: int activate(datastruct *data) where datastruct is defined as: typedef struct datastruct { long result;
0
by: harsha1305 | last post by:
Hi all, I need to create a pointer to array of structure. Definition of structure: typedef struct { char b_name; unsigned long int sig; unsigned long int count; volatile unsigned char...
0
by: friend.05 | last post by:
I have three files. graph.h: My header file where I have typedef for my structure and function delcaration typedef struct _ipc_actors ipc_graph_actors; typedef ipc_graph_type...
5
by: Sheikko | last post by:
Hi, friends. I am new in this group and I have a problem. I am just started to program in cSharp and I need a help. I need to import a ddl and to use one of its function. The function, in C...
14
by: Ron Blancarte | last post by:
I was looking through the newsgroup FAQ for an answer to my question, but it doesn't appear to have one. I am working with a system that has VERY limited memory. I was defining two buffers to...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.