Friday, August 29, 2014

Copy Constructor gonna F*** u over

a customized copy constructor that over-write the default one will not copy field you are not specified


Thursday, July 17, 2014

Write CMAKE find module

1. in order to make your own FindXXX.cmake be recognized by cmake, you 
need to add the directory holding the FindXXX.cmake to the module path as bellow 
 
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") 
 
2. write the path searching script

3. set the correct variable name for your library path variable

(To be updated)

Use AddressSanitizer with CMake project

AddressSanitizer is a fast alternative of Valgrind for memory error check. It based on a totally different mechanism that substitute all the memory allocation and free functions in your code and keep track all memory operations.

Clang integrated AddressSanitizer since 3.1 version. We can use it directly by adding some compiler flags for Clang.

Something like this:
clang -fsanitize=address -O1 -fno-omit-frame-pointer -g tests.cpp

With CMake projection, however, we need to add the flag in your make file.

The simplest thing would be to add the following in your make file:
set(CMAKE_CXX_FLAGS "-fsanitize=address -O1 -fno-omit-frame-pointer -g")