News for hackers. Stuff that matters.
Re:First chapter of Kernighan and Donovan's new Go book [pdf] by hactually on Monday October 19, 2015 @03:40PM (#10415167)
Isn't it funny how C has so many ways to accomplish the same thing. Why did you use a typedef with a tag?

  typedef struct {
    int a;
    int b;
  } Foo;

  Foo f = { .a = 1 };
Re:First chapter of Kernighan and Donovan's new Go book [pdf] by to3m on Monday October 19, 2015 @04:22PM (#10415449)
Tagless structs can't be forward-declared.

(Obviously, this looks like a local struct, so there's possibly no need for forward declaration. But you might have a snippet to generate this sort of thing for you. Or maybe it's just force of habit. And so on.)

Re:First chapter of Kernighan and Donovan's new Go book [pdf] by masklinn on Monday October 19, 2015 @04:25PM (#10415466)
> Or maybe it's just force of habit.

Or cargo-culting.

edit: wow somebody felt threatened. I have no shame stating that I cargo-culted exactly that for a while before I actually wondered what I was doing.

Re:First chapter of Kernighan and Donovan's new Go book [pdf] by TillE on Monday October 19, 2015 @04:47PM (#10415616)
I'm guilty of this when writing C. I really have no desire to learn the language properly (it's hard enough to fit C++ in my brain), so I'll just follow the patterns others have set.

Microsoft does stuff like:

    typedef struct _FOO {
        ...
    } FOO, *PFOO;
Yeah ok fine, I'll do that.
Re:First chapter of Kernighan and Donovan's new Go book [pdf] by to3m on Monday October 19, 2015 @04:53PM (#10415659)
When doing this in your own libraries, be sure to document how to generate the struct tag name from the typedef name. (MS don't do this - but they're not consistent about it anyway.) Then when people see a typedef'd struct used somewhere in a header, they'll know how to forward declare it in their own headers.
Re:First chapter of Kernighan and Donovan's new Go book [pdf] by voltagex_ on Monday October 19, 2015 @11:07PM (#10417182)
What's forward declaring mean?
Re:First chapter of Kernighan and Donovan's new Go book [pdf] by masklinn on Tuesday October 20, 2015 @02:48AM (#10417790)