How to define a variant record type in C
Dear Sir or Madam:
I am looking for help to define a variant record type in C. I am trying to map a Ada variant record data type into C data type, but I really dont know how to convert it into C. Here is the code
in Ada
Code:
type POWER is (GAS, STEAM, DIESEL, NONE);
type VEHICLE (Engine : POWER) is
record
Model_Year : INTEGER range 1888..1992;
Wheels : INTEGER range 2..18;
case Engine is
when GAS => Cylinders : INTEGER range 1..16;
when STEAM => Boiler_Size : INTEGER range 5..22;
Coal_Burner : BOOLEAN;
when DIESEL => Fuel_Inject : BOOLEAN;
when NONE => Speeds : INTEGER range 1..15;
end case;
end record;
Ford : VEHICLE(GAS);
Truck : VEHICLE(DIESEL);
Schwinn : VEHICLE(NONE);
Stanley : VEHICLE(STEAM);
Any C code example or explaining how to define this kind of data structure in C is greatly appreciated.
DiepVien_007