Is there a way to get warned about unused functions?

Caolan Mc Namara, a LibreOffice developer, has made a small tool to detect this type of thing in LibreOffice source code. They had around thousands functions & methods unused in LibreOffice. His tool is a key element for removing them. It’s called callcatcher. It can collect functions/methods defined and subtract called/referenced It works directly on … Read more

function declared static but never defined

A static function can be declared in a header file, but this would cause each source file that included the header file to have its own private copy of the function, which is probably not what was intended. Are u sure u haven’t included the abc.h file in any other .c files? Because declaring a … Read more

Is there a GCC option to warn about writing `this-field` instead of `this->field`?

This particular issue is detected by cppcheck: $ cppcheck –enable=all this-minus-bool.cxx Checking this-minus-bool.cxx… [this-minus-bool.cxx:7]: (warning) Suspicious pointer subtraction. Did you intend to write ‘->’? (information) Cppcheck cannot find all the include files (use –check-config for details) This was with no include path given. If I add -I /usr/include/c++/4.8/, the issue is still detected: Checking this-minus-bool.cxx… … Read more

Compile and run program without main() in C

Let’s have a look at the generated assembly of your program: .LC0: .string “Hello World…” .LC1: .string “Successfully run without main…” nomain: push rbp mov rbp, rsp mov edi, OFFSET FLAT:.LC0 call puts mov edi, OFFSET FLAT:.LC1 call puts nop pop rbp ret Note the ret statement. Your program’s entry point is determined to be … Read more

Pedantic gcc warning: type qualifiers on function return type

It doesn’t violate the standard. That’s why they’re warnings and not errors. And indeed you’re right — the leading const is superfluous. The compiler warns you because you’ve added code that in other circumstances might mean something, but in this circumstance means nothing, and it wants to make sure you won’t be disappointed later when … Read more

What exactly does GCC’s -Wpsabi option do? What are the implications of supressing it?

You only need to worry about ABIs when you are crossing library boundaries. Within your own applications/libraries the ABI doesn’t really matter as presumably all your object files are compiled with the same compiler version and switches. If you have a library compiled with ABI1 and an application compiled with ABI2 then the application will … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)