Thanks a lot. I was trying to write macro that generates: enum type and 
procedure to map value of this enum to related string. I decided to port game 
based on Freeciv. I'm only developer of this game and introducing a new 
features takes too long. Freeciv (and my game) is write in C and uses 
x-includes to generate code on compile time by macros. Given x-includes header 
takes as „argument” definitions of enum values and related strings by checking 
in the chain next enum value and related string is defined. It request to name 
definition in strict way, so this is good example: 
    
    
    #define SPECENUM_VAL0 PLAYER_GREEN
    #define SPECENUM_STR0 "Green"
    #define SPECENUM_VAL1 PLAYER_RED
    #define SPECENUM_STR1 "Red"
    .
    .
    .
    #define SPECENUM_VALN PLAYER_COLOR_n
    #define SPECENUM_STRN "Some color"
    
    #include "genereate_specenum.h"
    
    
    Run

I need to understood how macros in nim works to do similar thinks 
(generate_specenum.h generates enum type and functions translates enum value to 
related string and vice-versa). I found nim function, which converts enum value 
to string, but it do similar thing to nim's quote (or quoteStr - I don't 
remember) or hash/double hash (I don't remember) operator in C preprocesor.

Reply via email to