James Kanze
11/1/2008 8:57:00 AM
On Nov 1, 9:32 am, "dasca...@gmail.com" <dasca...@gmail.com> wrote:
> On Nov 1, 1:00 am, Boris Dušek <boris.du...@gmail.com> wrote:
> > #define LETTER_STRAIGHT(let) let = L'#let'
> <snip>
> > enum Letter {
> > A = L'#let',
> > B = L'#let',
> > C = L'#let',
> > };
> You could try
> #define LETTER_STRAIGHT(let) let = L#let[0]
> which should create
> > enum Letter {
> > A = L"A"[0],
> > B = L"B"[0],
> > C = L"C"[0],
> > };
> which should be functionally equivalent. You can't create a
> single char with preprocessor macros - it's always a string.
> You can then use the first char of that string, iirc.
You can, but the result of a dereferce operator is never a
constant expression, even if you're dereferencing a string
literal, so it can't be used as the initializer of an enum
constant (or an array dimension, or a template argument).
There are a number of different work-arounds possible, but
without knowing what problem he's trying to solve, it's
difficult to recommand any. Off hand, I don't see what the
problem is in writing:
enum Letter
{
A = L'A',
B = L'B',
C = L'C'
} ;
directly.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34