News for hackers. Stuff that matters.
Re:The Linux codebase has over 3k TODO comments, many from o... by john_moscow on Sunday December 29, 2019 @10:35PM (#21910622)
I use this pattern across my codebase for the "critical functionality missing" scenario:

  #if DEBUG
  #define TODO(msg)
  #else
  #define TODO(msg) #error msg
  #endif

Works like a charm. I've got another PRERELEASE() macro that lets you do an unofficial preview build, but would break an official stable release.
Re:The Linux codebase has over 3k TODO comments, many from o... by hvdijk on Monday December 30, 2019 @04:14AM (#21911983)
Macros cannot expand to preprocessing directives. This does not result in a #error-directive, this just results in a syntax error because of an unexpected # token. A better definition would be something that highlights that message in the error output, such as static_assert(0, msg).
Re:The Linux codebase has over 3k TODO comments, many from o... by Toury2d on Sunday December 29, 2019 @11:47PM (#21910886)
That doesn't sound like it would scale at all for any more than a couple of devs.
Re:The Linux codebase has over 3k TODO comments, many from o... by john_moscow on Sunday December 29, 2019 @11:54PM (#21910903)
Neither do TODO comments. This is just for a short-term "don't forget this piece before calling the current job done".

For anything more long-term you want to use a proper task management system with priorities, deadlines, dependencies and so on.

Re:The Linux codebase has over 3k TODO comments, many from o... by earenndil on Monday December 30, 2019 @12:50AM (#21911112)
Slight tweak:

    #if DEBUG
    #define TODO(msg) #warning msg
    #else
    #define TODO(msg) #error msg
    #endif
Re:The Linux codebase has over 3k TODO comments, many from o... by darkkindness on Monday December 30, 2019 @12:58AM (#21911141)
Nice! Isn't this exactly assert in C++? (the following is from https://en.cppreference.com/w/cpp/error/assert)

    #ifdef NDEBUG
    #define assert(condition) ((void)0)
    #else
    #define assert(condition) /*implementation defined*/
    #endif

    ...
    assert(("There are five lights", 2 + 2 == 5));
    ...

    test: test.cc:10: int main(): Assertion `((void)"There are five lights", 2+2==5)' failed.
Take it as a token that you are doing something right. :)
Re:The Linux codebase has over 3k TODO comments, many from o... by john_moscow on Monday December 30, 2019 @01:01AM (#21911159)
Assert's run-time. This is compile-time (i.e. all instances are guaranteed to trigger during build). C++ equivalent would be a static_assert, but it has a totally different use case like this:

  static_assert(sizeof(StructUsedInSomeBinaryProtocol) == SomeConstantExpectedByTheOtherSide, "<...>")
Re:The Linux codebase has over 3k TODO comments, many from o... by TeMPOraL on Monday December 30, 2019 @02:22AM (#21911460)
We used to do static asserts with a preprocessor macro that typedefed an array with size expressed as: (your condition) ? 1 : -1. Point being, static asserts have the use case you want them to have; I see no reason to not have a TODO macro that expands to static_assert(false, "...").