Hacker News new | ask | show | jobs
by zx2c4 1579 days ago
Here's the document for that change: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2841.htm

> In this proposal, a function declarator without a parameter list declares a prototype for a function that takes no parameters (like it does in C++).

And it seems like gcc implements this under -std=c2x now:

    zx2c4@thinkpad /tmp $ cat a.c
    int blah()
    {
            return 7;
    }
    
    int main(int argc, char *argv[])
    {
            return blah(argc);
    }
    zx2c4@thinkpad /tmp $ gcc -std=c17 a.c
    zx2c4@thinkpad /tmp $ gcc -std=c2x a.c
    a.c: In function ‘main’:
    a.c:8:16: error: too many arguments to function ‘blah’
        8 |         return blah(argc);
          |                ^~~~
    a.c:1:5: note: declared here
        1 | int blah()
          |     ^~~~