extern

R

Randy

city extern City *TheCity;

Hi,

I ran across this line, within a .h namespace, and I don't fully
understand it.

As I understand it, "extern" means that this "global" pointer to a
City is probably instantiated in another cc file.

What does the extra "city", before the extern, indicate?

I also see a member function, prefaced with "city", in the City class,
which makes me think that it has something to do with global
namespaces?

city static void ReadMe(...

Any help would be appreciated, my searches aren't turning up
anything.
 
V

Victor Bazarov

Randy said:
city extern City *TheCity;

I ran across this line, within a .h namespace, and I don't fully
understand it.

As I understand it, "extern" means that this "global" pointer to a
City is probably instantiated in another cc file.

What does the extra "city", before the extern, indicate?

Maybe that it's not from a village? Unless you tell us what 'city',
'City' are, it's impossible to make any conclusions. For all we know
it's a macro that expands into something.
I also see a member function, prefaced with "city", in the City class,
which makes me think that it has something to do with global
namespaces?

It makes me think that whoever wrote it didn't like country living.
city static void ReadMe(...

Any help would be appreciated, my searches aren't turning up
anything.

<shrug> My crystal ball is cloudy today.

V
 
R

Randy

Maybe that it's not from a village? Unless you tell us what 'city',
'City' are, it's impossible to make any conclusions. For all we know
it's a macro that expands into something.


It makes me think that whoever wrote it didn't like country living.



<shrug> My crystal ball is cloudy today.

V

ahaha ... I see your point. Sometimes one's psuedo code just ain't as
clear as one would expect. I'll recreate it and post a working pgm.
Thanx for the sublight response though.
 
A

Alf P. Steinbach

* Randy:
city extern City *TheCity;

Hi,

I ran across this line, within a .h namespace, and I don't fully
understand it.

As I understand it, "extern" means that this "global" pointer to a
City is probably instantiated in another cc file.
Yep.


What does the extra "city", before the extern, indicate?

I also see a member function, prefaced with "city", in the City class,
which makes me think that it has something to do with global
namespaces?

city static void ReadMe(...

Any help would be appreciated, my searches aren't turning up
anything.

It's probably a macro defined as some language extension keyword.

Search the code for the definition.

Or better, throw that code in the nearest flame-proof trashbin and do
whatever comes natural.


Cheers, & hth.,

- Alf
 
R

Randy

I found this earlier in the hierarchy:

#define city __declspec(dllexport)

Sooo ...

city extern City *TheCity;

TheCity is a pointer to a City type that may not be instantiated in
this file, and !!!! if you create a .dll, then expose (allow clients
using said dll to dllimport) this class. Correct ?

I am not in Kansas anymore, am I ...
 
V

Victor Bazarov

Randy said:
I found this earlier in the hierarchy:

#define city __declspec(dllexport)

Sooo ...

city extern City *TheCity;

TheCity is a pointer to a City type that may not be instantiated in
this file, and !!!! if you create a .dll, then expose (allow clients
using said dll to dllimport) this class. Correct ?

I am not in Kansas anymore, am I ...

The modifiers/qualifiers contained in __declspec are specific to
Microsoft Visual C++ compiler (and those compatible with it, like
Intel C/C++). Please ask for more information in the newsgroup
'microsoft.public.vc.language' or simply RTFM.

V
 
R

Randy

Sooo ... if I then asked if there were any differences between that
and __attribute__((visibility())) ... it'd be OT as well ?? lol
Thanx for the direction ... Me RTFM.
 
V

Victor Bazarov

Randy said:
Sooo ... if I then asked if there were any differences between that
and __attribute__((visibility())) ... it'd be OT as well ?? lol

I've never seen '__attribute__((visibility()))' in any C++ code that
came my way. 'fraid it's not standard C++...

Good luck!

V
 
T

Tomás Ó hÉilidhe

Randy:
#define city __declspec(dllexport)


It's been a few years since I've programmed for Windows, but as far as I
know, what that does is specify that a function is to appear in the
executable's export table, such that it can be accessed by using
GetProcAddress.
 
C

Christopher

I found this earlier in the hierarchy:

#define city __declspec(dllexport)

Sooo ...

city extern City *TheCity;

TheCity is a pointer to a City type that may not be instantiated in
this file, and !!!! if you create a .dll, then expose (allow clients
using said dll to dllimport) this class. Correct ?

I am not in Kansas anymore, am I ...

Welcome to the world of dealing with .dll's
I've been using C++ for a very long time and still have trouble
dealing with making things in a .dll visible to the client of
the .dll . Unfortunately, it is quite Windows specific and OT for this
newsgroup, but my advise isn't:

I'd start trying to understand them much the way I would any unknown
concept you run across. Make a test, that is as simple as possible,
outside of your project. In this case, create a .dll with one variable
declared in it, then make a client that used the .dll, gets that
variable, and displays it. That will help you understand what's
happening in your project...hopefully.

After you accomplish that, try the same with a function, and finally a
class.

How to do this should be a matter of a bit of google research.

Good luck!
 
J

James Kanze

I've never seen '__attribute__((visibility()))' in any C++ code that
came my way. 'fraid it's not standard C++...

Any symbol which starts with a double underscore results in
undefined behavior, according to the C++ standard. Of course,
anything the standard declares undefined, an implementation is
free to define. In general, as soon as I see such a symbol in
user code, it seems safe to suppose an implementation defined
extention. (And I'm surprised you've never seen __attribute__.
I've certainly seen it more often than I've seen __dclwhatever,
which won't even compile with the compilers I usually use.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,112
Latest member
VinayKumar Nevatia
Top