[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] Enum String Generator
From: |
Fam Zheng |
Subject: |
Re: [Qemu-devel] Enum String Generator |
Date: |
Sun, 15 Feb 2015 10:37:46 +0800 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Fri, 02/13 19:33, John Snow wrote:
> Just a stupid question: We don't have a macro facility in the current
> codebase that generates both an enum and string table / lookup function
> simultaneously, do we?
>
> Some things really do just wind up looking grossly inelegant in C, and this
> is one of them.
>
There is in QAPI:
address@hidden:~/build/last$ grep -A 4 NewImageMode_lookup qapi-types.c
const char *NewImageMode_lookup[] = {
"existing",
"absolute-paths",
NULL,
};
address@hidden:~/build/last$ grep -C 10 -e NEW_IMAGE qapi-types.h
...
extern const char *NewImageMode_lookup[];
typedef enum NewImageMode
{
NEW_IMAGE_MODE_EXISTING = 0,
NEW_IMAGE_MODE_ABSOLUTE_PATHS = 1,
NEW_IMAGE_MODE_MAX = 2,
} NewImageMode;
...
Is that what you want?
Fam