??? 11/11/11 09:10 Read: times |
#184630 - not necessarily Responding to: ???'s previous message |
Oliver Sedlacek said:
OP said:
typedef struct { BYTE ip_addr[4]; } IP_ADDR; IP_ADDR broadcast_IP = {255,255,255,255}; IP_ADDR zero_ip = {0, 0, 0, 0}; IP_ADDR ip_addrr; Shouldn't you have nested curly brackets, e.g. IP_ADDR broadcast_IP = {{255,255,255,255}}; IP_ADDR zero_ip = {{0, 0, 0, 0}}; IP_ADDR ip_addrr; I was going to answer the same, but then went out to study C99 once again, and turns out, no, you don't *need* that (although it's certainly a good idea). C99, 6.7.8#20 said:
If the aggregate or union contains elements or members that are aggregates or unions,
these rules apply recursively to the subaggregates or contained unions. If the initializer of asubaggregate or contained union begins with a left brace, the initializers enclosed by that brace and its matching right brace initialize the elements or members of the subaggregate or the contained union. Otherwise, only enough initializers from the list are taken to account for the elements or members of the subaggregate or the first member of the contained union; anyremaining initializers are left to initialize the next element or member of the aggregate of which the current subaggregate or contained union is a part. JW |