title: Defining symbolic string constants which have the same name and value
body: <p>I have a situation where I've got a number of strings that I want to be able to use symbolically, ie as if I'd declared a macro</p>
  
  <pre><code>#define kBlahProperty "kBlahProperty"
  #define kFooProperty "kFooProperty"
  </code></pre>
  
  <p>There are various reasons why I can't use an enum (for more context see this <a href="https://stackoverflow.com/questions/14342241/creating-debugger-friendly-enums-for-property-table">previous question</a>), such as getting useful info in the debugger, serialising data in a readable format and dealing with sets of properties defined in different source files.</p>
  
  <p>Typical usage:</p>
  
  <pre><code>setProperty(kBlahProperty, 6);
  if (otherProperty==kBlahProperty) { doStuff(); }
  std::cout &lt;&lt; "property type: " &lt;&lt; kBlahProperty;  // outputs "kBlahProperty" rather than an enum
  </code></pre>
  
  <p>There may be many of these properties, and to ease definition I'd like to be able to declare them like this, in one place only:</p>
  
  <pre><code>DEFINE_PROPERTY(kBlahProperty)
  DEFINE_PROPERTY(kFooProperty)
  </code></pre>
  
  <p>However, I can't find a way of defining a macro that will itself expand to #define (I've tried a couple of examples with the '#' and '##' operators, but getting to paste the '#define' is the problem).</p>
  
  <p>An alternative tack was to define the macro to expand as a <code>char*</code>: </p>
  
  <pre><code>#define DEFINE_PROPERTY(propName) const char8* propName=#propName
  </code></pre>
  
  <p>but this has the problem that it gets defined in each compilation unit and hence linker errors. If I change it to use <code>extern</code> then I can't define it to use the string itself -- that has to go in the .cpp file and so now I would need to declare all these properties in the header and define them again in the cpp file, so you have a list in two places.</p>
  
  <p>So is there a good way of defining these strings so that you can just declare them once?  I have access to boost preprocessor, but only to a small subset of C++-0x (so <a href="http://www.stroustrup.com/C++11FAQ.html#member-init" rel="nofollow noreferrer">in-class constant initialisers</a> are out).</p>