Modern C++ Course [Lecture 2] {Compilation, Debugging, Functions, Header/Source, Libraries, CMake}

http://www.ipb.uni-bonn.de/wp-content/uploads/2018/05/lecture_2.pdf


 make bash file executable

 

 Wall: Warning all

Wextra: add even more extra Warning

Werror: treat Warnings as errors

 

by default, there's no optimization.

-O0

-O3 -Ofaster 

 

 

"segmentation fault" means you are using some unallowed memory.

 

 

use reference to avoid copy, and save a lot time!

 explaining how reference as function variable works.

 

 

Announce default variables only in declaration (typo above...).

sort, sumation, multiplication standard operation in std::vector

 

 every header file should include "#pragma once", otherwise you would get wierd errors.

 

 

the compiler doesn't know the definition of the test.cpp.

 

simply add the 2nd line will make the "c++ main.cpp ... " work, but no output!

build the test.cpp first, and include the result .o file into main.cpp building.

     c++ workflow!!!

.o file is binary and only machine can read it.

 

 

  maybe there's a branch of changing now in makefile. but this file is simple and readable.

 

 

猜你喜欢

转载自www.cnblogs.com/ecoflex/p/10182982.html