News for hackers. Stuff that matters.
Re:Resume in C by Aldo_MX on Tuesday March 17, 2015 @02:04AM (#9216518)
Wow, I didn't know this was valid C code, it's pretty convenient.

  school_t uiuc = {
      .school   = "University of Illinois at Urbana-Champaign",
      .location = "Urbana, IL",
      .program  = "BS Computer Science",
      .started  = 1251158400,
      .left     = 1336608000,
      .accomplishments = {
          "Minor in International Studies in Engineering, Japan",
          "Focused on systems software courses",
          NULL
      }
  };
Re:Resume in C by wschroed on Tuesday March 17, 2015 @09:27AM (#9217693)
I highly recommend "21st Century C" (http://shop.oreilly.com/product/0636920025108.do) as a tour of modern C programming, including use of C99 features. It goes over C tooling (profiling, debugging, testing, cross-platform deployment), and explores C99.
Re:Resume in C by pwaring on Tuesday March 17, 2015 @10:43AM (#9218238)
There's a newer edition available which has been published recently:

http://shop.oreilly.com/product/0636920033677.do

Re:Resume in C by Aldo_MX on Tuesday March 17, 2015 @03:48PM (#9220801)
Following your recommendation, to people interested in learning about Modern C++, Stroustrup's Tour of C++ is a recommended read.

http://www.stroustrup.com/Tour.html

Re:Resume in C by cipher0 on Tuesday March 17, 2015 @04:42AM (#9216845)
These are called desginated initializers, they're part of C99.[0] This is a good read which discusses them and also devles into compound literals.[1]

[0] https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html [1] https://nickdesaulniers.github.io/blog/2013/07/25/designated...

Re:Resume in C by lcampbell on Tuesday March 17, 2015 @02:22AM (#9216553)
It's a C99 feature (I think?) -- designated literals. They're absolutely wonderful.
Re:Resume in C by masklinn on Tuesday March 17, 2015 @06:07AM (#9217068)
Although GP didn't remark on it, TFA uses an other cool feature which is actually C11: anonymous unions. Although not as wonderful as designated literals, they're really quite convenient.
Re:Resume in C by amaterasu on Tuesday March 17, 2015 @02:34AM (#9216587)
It's supported by GCC as an extension to C90 too.
Re:Resume in C by samatman on Tuesday March 17, 2015 @03:11AM (#9216649)
what does that even mean? Isn't C99 an extension of C90/ANSI? Doesn't GCC support the whole of C99 as an extension to ANSI?
Re:Resume in C by masklinn on Tuesday March 17, 2015 @03:43AM (#9216711)
It means that GCC will allow/support this even if you set it to std=c89 or std=c90.
Re:Resume in C by michaelmior on Tuesday March 17, 2015 @07:09AM (#9217209)
Won't that only be supported in gnu89 or gnu90 mode?
Re:Resume in C by edmccard on Tuesday March 17, 2015 @08:57AM (#9217552)
No, it will be supported using -std=c89 or -std=90, unless you also specify -pedantic.
Re:Resume in C by michaelmior on Tuesday March 17, 2015 @12:53PM (#9219299)
Yes, I realized after posting that -pedantic is required for strict standards compliance.
Re:Resume in C by mikeash on Tuesday March 17, 2015 @11:48AM (#9218736)
The GNU modes just enable additional features which conflict with plain C. Any feature which can coexist with plain C will be enabled in the regular C modes too. For example, __typeof__ is enabled everywhere, because the compiler is allowed to do just about anything it wants with a __ prefix, but plain typeof is only enabled in the GNU modes, since it could cause valid C programs using "typeof" for their own purposes to fail to compile.
Re:Resume in C by dhekir on Tuesday March 17, 2015 @08:28AM (#9217439)
C99 is not a strict extension, but as stated in its foreword, "this second edition [C99] cancels and replaces the first edition [C90]".

For instance, implicit function declarations are allowed in C90 but not in C99.

Re:Resume in C by blt on Tuesday March 17, 2015 @11:04AM (#9218363)
I so, so wish C++ would adopt this feature.
Re:Resume in C by stephencanon on Tuesday March 17, 2015 @03:00PM (#9220397)
Designated initializers are one of a few indispensable features that make "C++ is a better C" a complete non-starter for me.
Re:Resume in C by pwaring on Tuesday March 17, 2015 @10:45AM (#9218244)
They're used heavily in Linux device drivers, amongst other things - here's just one example:

https://github.com/torvalds/linux/blob/master/drivers/video/...

Re:Resume in C by zem on Tuesday March 17, 2015 @03:50AM (#9216721)
i learnt about them from this post and the library it refers to: http://spin.atomicobject.com/2014/10/08/c99-api-designated-i...

good read, both the post and the socket99 code.

Re:Resume in C by amitlan on Tuesday March 17, 2015 @04:00AM (#9216748)
My gcc required me to put { } around any fields of unnamed unions.

[gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)]

Re:Resume in C by GFK_of_xmaspast on Tuesday March 17, 2015 @02:26PM (#9220134)
gcc 4.4 is getting kind of long in the tooth.