Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > const char* as a static member

Reply
Thread Tools

const char* as a static member

 
 
Alex Vinokur
Guest
Posts: n/a
 
      09-12-2006
Is this library safe?

Does this have to do with Position Independent Code?

====== Library ======

--- File foo.h ---

struct Foo
{
static const char* s_name;
// Stuff
};

-------------------

--- File foo.cpp ---

const char* Foo::s_name = "ABCD";

// Stuff

-------------------

====================



Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn

 
Reply With Quote
 
 
 
 
Ivan Vecerina
Guest
Posts: n/a
 
      09-12-2006
"Alex Vinokur" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
: 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
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <> http://www.brainbench.com

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
const correctness - should C++ prefer const member over non-const? fungus C++ 13 10-31-2008 05:33 AM
static const T vs static T const er C++ 3 04-22-2008 10:22 PM
const vector<A> vs vector<const A> vs const vector<const A> Javier C++ 2 09-04-2007 08:46 PM
const static Vs. static const Dave C++ 10 05-22-2005 10:32 PM
About static const members appearing in another static const definitions Rakesh Sinha C++ 4 01-13-2005 08:11 AM



Advertisments