News for hackers. Stuff that matters.
Re:How to properly use macros in C by tomsmeding on Sunday December 10, 2017 @05:23PM (#15893811)
> Some compilers offer debug strings in macros, which cannot be used in functions: __FILE__, __LINE__, __func__.

But... Of course they can. They are just symbols defined by the compiler, and have nothing to do with being in a macro expansion or not. Heck, they are probably implemented as macro's themselves inside the preprocessor.

Re:How to properly use macros in C by jstimpfle on Sunday December 10, 2017 @05:37PM (#15893860)
What he means is, you want to use them in a macro. You can't get the effect you probably want by using them in a function. Compare:

    #define LOG_ERROR() printf("ERROR at %s:%d\n", __FILE__, __LINE__)
    void logError(void) { printf("ERROR at %s:%d\n", __FILE__, __LINE__); }
Re:How to properly use macros in C by tomsmeding on Sunday December 10, 2017 @06:20PM (#15894051)
Sure, they are pretty useless in a function. But that doesn't mean that the author can go and use incorrect language. :P
Re:How to properly use macros in C by AstralStorm on Monday December 11, 2017 @02:27AM (#15895649)
Except when they work properly when fully inlined. (Sprinkle GCC/Clang magic here. It is required to make it work.)
Re:How to properly use macros in C by tomsmeding on Monday December 11, 2017 @04:53AM (#15896077)
Is that even possible? It shouldn't be without extensions. (But that seems to be what you're implying anyway.)