Slacker News Slacker News logo featuring a lazy sloth with a folded newspaper hat
  • top
  • new
  • show
  • ask
  • jobs
Library
← Back to context

Comment by 1718627440

1 month ago

Sorry, but I wouldn't like that either. I often intentionally don't initialize members and don't want that to be an error. How would you initialize the following:

    struct S  {
         enum {
              NO_MODE,
              MODE_A,
              MODE_B,
              MODE_C,
         } mode;
         union {
             struct mode_a {
                 float x, y;
             } a;
             struct mode_c {
                 time_t start;
                 bool flag;
             } c;
         };
    };

    S s;
    s.mode = NO_MODE;

?

0 comments

1718627440

Reply

No comments yet

Contribute on Hacker News ↗

Slacker News

Product

  • API Reference
  • Hacker News RSS
  • Source on GitHub

Community

  • Support Ukraine
  • Equal Justice Initiative
  • GiveWell Charities