Use C++ and build a class. Or, use C and enums. You cannot enforce the behaviour you want in C easily. Yes it can be done. No, it's not easy. Use C++.
[edit]
Code:
/* type POWER is (GAS, STEAM, DIESEL, NONE); */
typedef enum { NONE, GAS, STEAM, DIESEL } POWER;
/*
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;
*/
typedef struct {
unsigned char Model_Year;
unsigned char Wheels;
POWER Type;
union
{
struct
{
unsigned char Cylinders;
} Gas;
struct
{
unsigned char Boiler_Size;
unsigned char Coal_Burner;
} Steam;
struct
{
unsigned char Fuel_Inject;
} Diesel;
struct
{
unsigned char Speeds;
}
} Engine;
} VEHICLE;
/* Ford : VEHICLE(GAS); */
VEHICLE Ford;
SetWheels( &Ford, 4 ); /* This would assign the value. */
SetYear( &Ford, 1983 ); /* This would assign the value. */
SetEngine( &Ford, GAS ); /* This would prompt for the correct values. */
It is up to you to enforce the values correctly. You really want C++.
[/edit]
Quzah.