C++ Review


  • CMake — build system generator
    • You use this define how to compile your code
  • gcc/g++/clang/clang++ — compilers
    • compilers turn your code into binaries
    • gcc and g++ are the GNU C and C++ compilers, respectively
    • clang and clang++ are the LLVM compilers, respectively
    • Use CMake to define how to invoke compilers on the source code files
  • gdb/lldb — debuggers
    • gdb is a debugger provided by GNU
    • lldb is a debugger provided by LLVM
    • Use these to detect issues when running your binaries
    • It generally does not matter which compiler was used to generate the binary, i.e. you can use LLDB to debug a code compiled with a GNU compiler or vice versa

Source: Quora






1.What’s the difference between #include<filename> and #include “filename”?

For #include <filename> the preprocessor searches in an implementation dependent manner, normally in search directories pre-designated by the compiler/IDE. This method is normally used to include standard library header files.

For #include "filename" the preprocessor searches first in the same directory as the file containing the directive, and then follows the search path used for the #include <filename> form. This method is normally used to include programmer-defined header files.

Link: answer from stackoverflow.


An example of creating simple Makefile for your project:

# CC=g++


default:	main

main:	main.cc ds_cnn.o 
	g++ -c main.cpp -o ds_cnn_executor

ds_cnn.o: ds_cnn.cc ds_cnn.h ds_cnn_large_quantized_model_data.o
	g++ $(INC) $(FLATBUFFER) $(THIRD_PARTY_CC_HDRS) -c ds_cnn.cc

ds_cnn_large_quantized_model_data.o: ds_cnn_large_quantized_model_data.cc ds_cnn_large_quantized_model_data.h
	g++ -c ds_cnn_large_quantized_model_data.cc

	rm ds_cnn.o ds_cnn_large_quantized_model_data.o ds_cnn_executor