473,727 Members | 1,989 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pointer to extern char?

While reading the page on "Reading C Declarations"
<http://www.ericgiguere .com/articles/reading-c-declarations.ht ml>
(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 6402
"coder" <pl***********@ gmail.comwrote in message
news:11******** **************@ 80g2000cwy.goog legroups.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************ **********@80g2 000cwy.googlegr oups.com>
coder <pl***********@ gmail.comwrote:
>While reading the page on "Reading C Declarations"
<http://www.ericgiguere .com/articles/reading-c-declarations.ht ml>
(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************ **********@80g2 000cwy.googlegr oups.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
2394
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
2534
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 going to hell just by using dlopen()/LoadLibrary() respectively, I'm still trying to get it as clean as possible. I have a number of different quantums of data and a number of plugins. Since any plugin can (and possibly will) touch any quantum...
6
1774
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 project (due to C# limits). What would be the other best way to do this? I would like to be able to use the original struct because these structs have over 40 members each and there are several more Structs similar to 4_PARM. Also, they are modified...
2
4066
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: ++++++++ C Header file start ++++++++++++++++++++++++++++++ #ifndef __UFISC_H #define __UFISC_H
4
2373
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
1982
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 *Su_buffer;
0
300
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 *ipc_graph_pointer;
5
2239
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 language, require in input a pointer char: OpenFile(char* filename); To use this function in cSharp I have writing the following code: =============================================
14
1782
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 pass in and out data: unsigned char inputBuffer; unsigned char outputBuffer; But now it turns out I need the output buffer to be larger under
0
9402
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9120
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8101
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4521
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4785
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2639
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.