4 ms·
I don't write C at all but aren't there code analysis tools that catch things like this? Some kind of standard code linting library, maybe?
by psychometry 12y ago
I don't write C at all but aren't there code analysis tools that catch things like this? Some kind of standard code linting library, maybe?
- andrewchambers 12y agoYes, the point is that these are obvious flaws, and dlink didn't even fix them. Someone from the dlink team just sucks. edit: And that someone may not even be the developer, at the end of the day, the company does not have the systems in place for quality control.
- jheriko 12y agoYes there are these things, although usually more focused on C++ these days. Compiling C as C++ with a C++ compiler is not a bad idea though... many compilers which will deal with both and tend not to care about pure C very much at all. Modern, extremely popular compilers may not even support C89 features yet... not to mention that lots will allow dangerous things like returning nothing from a function with a non void return type without even a compile error. Many tools can catch the bugs mentioned here though - things like PVS studio, cppcheck, or the built in visual studio or xcode analysers (I would never recommend pc-lint, sorry), and some of these things mentioned are compiler warnings in some cases (sprintf will trigger the endlessly annoying CRT_NO_SECURE_WARNINGS message from the ms compiler for instance).
- rpcope1 12y agoModern, extremely popular compilers may not even support C89 features yet... Citation needed please. Also, because C is not a true subset of C++, it has seemed that many big C projects will not compile on C++ compilers because of corner cases, so this may be something to watch for. Much of the incompatibility rises from additions in C99. References: (http://www.geeksforgeeks.org/write-c-program-wont-compiler-c/ http://www.geeksforgeeks.org/write-c-program-wont-compiler-c..., http://david.tribble.com/text/cdiffs.htm#C90-vs-CPP98 http://david.tribble.com/text/cdiffs.htm#C90-vs-CPP98)
- jheriko 12y agowell spotted, that should have been C99, of which many features are not supported with the ms compiler. i believe that the variable array thing was pulled in C11 because so few compilers ever bothered to support it... i see problems with it regularly where we use c code that goes through clang just fine, but cl complains. not putting declarations at the top of a file or scope is the obvious example that comes to mind and constantly snags people... that being said there are even C++ problems, although smaller. for instance, its impossible to use the preprocessor variadic macros across cl, clang, gcc without getting warnings from at least one of them. i like to run with warnings as errors and the highest warning settings possible. i'm not going to bother digging up references for informal conversation... but thanks for catching the mistake.