Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Jan Waclawek
11/11/11 02:10
Read: 478 times
Bratislava
Slovakia


 
#184630 - not necessarily
Responding to: Oliver Sedlacek'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



List of 39 messages in thread
TopicAuthorDate
Keil problem...      Lukas Valecky      11/10/11 03:53      
   Kel support      Per Westermark      11/10/11 05:41      
      Keil support      Erik Malund      11/10/11 06:49      
         Reward for finding bug      Bert Van Den Berg      11/10/11 10:27      
            been tried      Erik Malund      11/10/11 10:51      
               public bug tracker      Maarten Brock      11/11/11 01:09      
                  It's not a KEIL-specific problem ...      Richard Erlacher      11/21/11 11:18      
                     not really      Maarten Brock      11/22/11 03:56      
                        It's those "snapshots" that I meant      Richard Erlacher      11/22/11 07:49      
                           Not true        Per Westermark      11/22/11 08:05      
                              Remember, where you sit determines what you see      Richard Erlacher      11/22/11 22:18      
                                 Concept      Per Westermark      11/23/11 02:11      
                                 I do not ...      Erik Malund      11/23/11 07:04      
                                    Comfort contra mobile phone      Per Westermark      11/23/11 08:30      
                                       Where you sit determines what you see ...      Richard Erlacher      11/24/11 00:58      
                                          You are still assuming you know what other people think/do        Per Westermark      11/24/11 02:49      
                                             You've overlooked the most basic fact ...      Richard Erlacher      11/24/11 16:31      
                                                Unuseful toy?      Per Westermark      11/24/11 17:18      
                                                   Once again, you've missed the point ...      Richard Erlacher      11/26/11 08:46      
                                                      Look for progress, instead of just looking back at history      Per Westermark      11/26/11 10:36      
                                                         are you that lucky?      Erik Malund      11/26/11 10:46      
                                                            Yes      Per Westermark      11/26/11 11:17      
                                                         Consider my position      Richard Erlacher      11/27/11 00:26      
      keil update      Lukas Valecky      11/10/11 07:47      
         auto variables      Per Westermark      11/10/11 08:24      
   Global Variable Initiaization      Michael Karas      11/10/11 06:40      
   just curious      Erik Malund      11/10/11 07:53      
      Always good to hide black-box data in structs      Per Westermark      11/10/11 08:19      
      Initialising array inside struct      Oliver Sedlacek      11/11/11 01:48      
         not necessarily      Jan Waclawek      11/11/11 02:10      
      Library      Lukas Valecky      11/11/11 05:00      
   New facts...      Lukas Valecky      11/11/11 06:35      
      At the very least use static for one-time initialized locals      Per Westermark      11/11/11 06:49      
         it works! thanks...      Lukas Valecky      11/15/11 11:36      
            Look at code in Debugger. It will tell all.      Michael Karas      11/15/11 12:19      
               It's called "Overlaying"      Andy Neil      11/15/11 15:00      
                  Optimization      Per Westermark      11/15/11 15:34      
      are you sure ...      Erik Malund      11/11/11 06:51      
   Thanks...      Lukas Valecky      11/21/11 10:55      

Back to Subject List