const char* as a static member

Discussion in 'C++' started by Alex Vinokur, Sep 12, 2006.

  1. Alex Vinokur

    Alex Vinokur Guest

    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
    Alex Vinokur, Sep 12, 2006
    #1
    1. Advertising

  2. "Alex Vinokur" <> wrote in message
    news:...
    : 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
    Ivan Vecerina, Sep 12, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Santa
    Replies:
    1
    Views:
    1,072
    Mark A. Odell
    Jul 17, 2003
  2. Replies:
    24
    Views:
    827
    Netocrat
    Oct 30, 2005
  3. lovecreatesbeauty
    Replies:
    1
    Views:
    1,034
    Ian Collins
    May 9, 2006
  4. Javier
    Replies:
    2
    Views:
    558
    James Kanze
    Sep 4, 2007
  5. fungus
    Replies:
    13
    Views:
    883
    fungus
    Oct 31, 2008
Loading...

Share This Page