[gmx-developers] A question about 'enum' datatype in Gromacs, ask for help

Erik Marklund erikm at xray.bmc.uu.se
Fri Mar 11 15:52:52 CET 2011


In C++, however, the tag is not optional as far as I know. But please do 
correct me if I'm wrong.

Erik Marklund skrev 2011-03-11 15.46:
> No, the syntax is:
>
> enum [ tag ] { sun, mon,... };
>
> where the tag is optional.
>
> Yukun Wang skrev 2011-03-11 15.25:
>> Hi,
>> I am recently reading the GMX src-code for some need. I notice there 
>> are many 'enum' typy defination in the 'enums.h' file. They are just 
>> like this:
>>
>> ...
>> enum {
>>   epbcXYZ, epbcNONE, epbcXY, epbcSCREW, epbcNR
>> };
>>
>> enum {
>>   etcNO, etcBERENDSEN, etcNOSEHOOVER, etcYES, etcANDERSEN, 
>> etcANDERSENINTERVAL, etcVRESCALE, etcNR
>> };
>> ...
>>
>> However in the standard C, enum type should be defined like ' enum 
>> enumtypename { Sum, Mon,...,Sat } enumname1 ' .
>> For the GMX code above I don't understand how it is work?
>>
>> I also notice there is a note ' /* note: these enums should 
>> correspond to the names in gmxlib/names.c */' ,
>> ...
>> const char *epbc_names[epbcNR+1]=
>> {
>>   "xyz", "no", "xy", "screw", NULL
>> };
>>
>> const char *ens_names[ensNR+1]=
>> {
>>   "Grid","Simple", NULL
>> };
>> ...
>> I just don't know how the two files are matched automatically. Is any 
>> suggestion about this?
>>
>>
>>
>>
>
>


-- 
-----------------------------------------------
Erik Marklund, PhD student
Dept. of Cell and Molecular Biology, Uppsala University.
Husargatan 3, Box 596,    75124 Uppsala, Sweden
phone:    +46 18 471 4537        fax: +46 18 511 755
erikm at xray.bmc.uu.se    http://folding.bmc.uu.se/




More information about the gromacs.org_gmx-developers mailing list