Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

While many of these warnings can be annoying during development they are also very useful if the code is kept clean of them. In this case the __bounded__ attribute is a security feature their compiler version has. If another platform can not support this feature then revoking this specific instance of this warning is an active decision someone should make when writing the build scripts. Just ignoring all warnings is certainly not the way to go.

The language often (always?) has facilities to remove those warnings on a case by case basis. For example when you don't want to use a parameter you can actively let the compiler know without assigning the variable to itself: you can only include the type and not the name:

    int fn(int, void*);
    
    int fn(int num, void* /*extra*/) {
        // If the name extra is commented out the compiler will
        // not warn that you are not using it. Now it is very
        // clear that not using this variable was an active choice
        // and not a mistake.
        return num;
    }
edit: as pbsd pointed out commenting out extra is not portable C code, though I believe the wider point still stands. These warnings can be very useful and should be be reviewed before ignoring them.


Omitting `extra` is only valid in C++, not C. In C you have to get by with things like

    (void)extra;
to shut the compiler up.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: