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

A warning would be nice, is there a way to implement that without changing the compiler though?


Something along these lines should work, for at least both of GCC and Clang:

    extern void banned() __attribute__((deprecated("This function is problematic")));

    #define strcpy(...) strcpy(__VA_ARGS__); banned;
Which would output something along the lines of:

    test.c:11:3: warning: 'banned' is deprecated: This function is problematic [-Wdeprecated-declarations]
  strcpy(x, y);


MSVC does this, or at least did the last time I had to compile C code for windows. You should be able to do it with the preprocessor if you wanted to.




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

Search: