const char* as a static member

I

Ivan Vecerina

: Is this library safe?
The posted code is perfectly safe according to the C++
standard.

: ====== Library ======
:
: --- File foo.h ---
:
: struct Foo
: {
: static const char* s_name;
: // Stuff
: };
:
: -------------------
:
: --- File foo.cpp ---
:
: const char* Foo::s_name = "ABCD";
:
: // Stuff
:
: -------------------
:
: ====================

: Does this have to do with Position Independent Code?

Position Independent Code does not "exist" in C++.
As I understand it, PIC is an implementation detail of
generated code on some platforms, where only PC-relative
addresses are used to allow the code to be relocated
in memory without requiring any absolute address fixing.
I don't see that the above code illustrates anything
specifically related to PIC.
http://en.wikipedia.org/wiki/Position_independent_code


Cheers --Ivan
 

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,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top