473,699 Members | 2,416 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 6400
"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
2392
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
2530
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
4065
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
2372
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
1979
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
2237
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
1780
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
8691
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8620
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9038
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8920
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8887
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
4378
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
4633
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3060
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2012
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.