Below I have the code for a struct in a program I'm writing. I would like to be able to initialize these parameters in some sort of loop, but I can't seem to figure out how to configure the .water/.air/.purge properties to update with the loop. nozzle_count is 16 so I would like to find a way to achieve the code below without having to just copy and paste it 16 times. I'd appreciate any input. Thanks!
static nozzle nozzles[nozzle_count] = {
{
.water = C1_WATER, .air = C1_AIR, .purge = C1_PURGE,
.interval = 15*60*1000, .cycle = 0*3*5*1000, .purge_length = 0*4*1000,
.state = WAIT
},
{
.water = C2_WATER, .air = C2_AIR, .purge = C2_PURGE,
.interval = 2*60*1000, .cycle = 1*3*1000, .purge_length = 0*4*1000,
.state = WAIT
},
{
.water = C3_WATER, .air = C3_AIR, .purge = C3_PURGE,
.interval = 2*60*1000, .cycle = 0*1*5*1000, .purge_length = 0*4*1000,
.state = WAIT
}
{
.water = C4_WATER, .air = C4_AIR, .purge = C4_PURGE,
.interval = 2*60*1000, .cycle = 0*1*5*1000, .purge_length = 0*4*1000,
.state = WAIT
}
{
.water = C5_WATER, .air = C5_AIR, .purge = C5_PURGE,
.interval = 2*60*1000, .cycle = 0*1*5*1000, .purge_length = 0*4*1000,
.state = WAIT
}
};
constexprand/or template magic, but yeah, in C you'd be limited to truly terrible recursive macros, where the cure is worse than the disease.intervalandcycleappear to change. Is that by accident? If not, how do you derive those values?C1_WATER,C1_AIR,C2_WATERetc.