News for hackers. Stuff that matters.
Re:Tbox: A GLib-like cross-platform C library by waruqi on Thursday April 11, 2019 @10:15PM (#19641342)
c99
Re:Tbox: A GLib-like cross-platform C library by Gibbon1 on Friday April 12, 2019 @02:02AM (#19642367)
Not supporting obsolete versions of C is utterly awesome.
Re:Tbox: A GLib-like cross-platform C library by waruqi on Friday April 12, 2019 @02:12AM (#19642406)
C89 is too old, too many grammar restrictions. And now the mainstream compiler basically supports c99.
Re:Tbox: A GLib-like cross-platform C library by Crinus on Friday April 12, 2019 @07:16AM (#19643769)
What grammar restrictions? I've converted a few C99 libraries to C89 (since i prefer that one and i often work with older compilers because they are faster) and 99% of the time the reason a library uses C99 is inline variable declaration (which IMO is a bad style, but that is subjective) and // comments (which most C89 compilers support as an extension anyway).

The versions do have other differences, of course, but they're rarely used (the next most common one is designated initializers, which for me are the most annoying to convert).

I mean, it is your code, i just found the grammar restrictions part weird since really there isn't that much of a practical difference between C99 and C89 to the point i personally never felt the need to use C99.

(note that i focus on the language bits, C99 provides some extra library functionality but even then the most useful part is stdint.h which can be implemented in almost any C89 compiler anyway)

Re:Tbox: A GLib-like cross-platform C library by waruqi on Friday April 12, 2019 @08:07AM (#19644032)
C89 cannot mix variable declarations and code.

    printf("Hello World!\n");
    int x = 7;
    printf("%d!\n", x);
    return 0;

This is a very serious restriction for me.
Re:Tbox: A GLib-like cross-platform C library by Crinus on Friday April 12, 2019 @10:39AM (#19645167)
Yes, that is what i meant with "inline variables". IMO this is usually a sign of code that is too long to be readable and if you really need that you should either split the function to make it more readable or, if that cannot be done, enclose the affected code in their own brackets (with a comment that makes it easy to distinguish). Brackets also make sure that the variable wont "outlive" its context (although again that is a sign of code that is too long).

Of course that is my opinion (and i'm generalizing of course), but that comes from my experience with working with others' code.

Re:Tbox: A GLib-like cross-platform C library by waruqi on Friday April 12, 2019 @10:53AM (#19645271)
Even if the function code is very short, I still like to define and declare variables nearby.

Unless a function has only two lines of code.

Re:Tbox: A GLib-like cross-platform C library by Crinus on Friday April 12, 2019 @11:20AM (#19645562)
Right, that is your style, but i wouldn't call that "too many grammar restrictions" :-).
Re:Tbox: A GLib-like cross-platform C library by WoodenChair on Friday April 12, 2019 @11:43AM (#19645820)
It's too many grammar restrictions for this person. That's obviously what's implied by the person's original comment.
Re:Tbox: A GLib-like cross-platform C library by Gibbon1 on Friday April 12, 2019 @03:03AM (#19642642)
That could be interpreted as sarcasm. It's not.
Re:Tbox: A GLib-like cross-platform C library by ensiferum on Friday April 12, 2019 @03:59AM (#19642932)
some would say that C itself is obsolete.. Ok, I can hear a bunch of people already piping up and whining how they're programming on a 8-bit toaster and only have a C compiler..but apart from that there are no real reasons to use C anymore since it's obsolete.
Re:Tbox: A GLib-like cross-platform C library by Gibbon1 on Friday April 12, 2019 @04:19AM (#19643011)
Until rust came along you had three non CG options C, C++ and ADA. If you also have a no heap requirement you're left with just C and ADA.

Rust is interesting if you can live with slow compile times and 4X the memory footprint of C.

Re:Tbox: A GLib-like cross-platform C library by keldaris on Friday April 12, 2019 @05:48AM (#19643434)
Why does the no heap requirement preclude C++? Obviously, you couldn't use much of the STL (not really a loss in constrained environments), but I don't see a reason to write off the language itself?
Re:Tbox: A GLib-like cross-platform C library by nickpsecurity on Friday April 12, 2019 @11:32AM (#19645717)
It is used in embedded. I think that refutes the claim.
Re:Tbox: A GLib-like cross-platform C library by steveklabnik on Friday April 12, 2019 @08:04AM (#19644017)
The memory footprint thing shouldn’t be different now; we stopped using jemalloc by default.