How can I use the tool ‘Include What You Use’ together with CMake to detect unused headers?

CMake 3.3 introduced the new target property CXX_INCLUDE_WHAT_YOU_USE that can be set to the path of the program include-what-you-use. For instance this CMakeLists.txt cmake_minimum_required(VERSION 3.3 FATAL_ERROR) add_executable(hello main.cc) find_program(iwyu_path NAMES include-what-you-use iwyu REQUIRED) # If using CGAL<3.18, you remove REQUIRED and use # if(NOT iwyu_path) # message(FATAL_ERROR “Could not find the program include-what-you-use”) # endif() … Read more

multiple definition in header file

The problem is that the following piece of code is a definition, not a declaration: std::ostream& operator<<(std::ostream& o, const Complex& Cplx) { return o << Cplx.m_Real << ” i” << Cplx.m_Imaginary; } You can either mark the function above and make it “inline” so that multiple translation units may define it: inline std::ostream& operator<<(std::ostream& o, … Read more

C/C++ header and implementation files: How do they work?

The header file declares functions/classes – i.e. tells the compiler when it is compiling a .cpp file what functions/classes are available. The .cpp file defines those functions – i.e. the compiler compiles the code and therefore produces the actual machine code to perform those actions that are declared in the corresponding .hpp file. In your … Read more

error C2039: ‘string’ : is not a member of ‘std’, header file problem

You need to have #include <string> in the header file too.The forward declaration on it’s own doesn’t do enough. Also strongly consider header guards for your header files to avoid possible future problems as your project grows. So at the top do something like: #ifndef THE_FILE_NAME_H #define THE_FILE_NAME_H /* header goes in here */ #endif … Read more

How to make Xcode find file FacebookSDK.h?

First, you have to remove your FacebookSDK.framework from your Project. Then start over again with these 5 steps. DO NOT re-link the framework. Go to Build Phases in your Project Target. In Link Binary With Libraries, click the “+” button. Click on “Add Other…” button Browse your FacebookSDK folder. Generally in ~/Documents/FacebookSDK/ Clik on (select) … Read more

C++ namespace and include

using directives and include preprocessor directives are two different things. The include roughly corresponds to the CLASSPATH environment variable of Java, or the -cp option of the java virtual machine. What it does is making the types known to the compiler. Just including <string> for example will make you able to refer to std::string : … Read more

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