Header file to prevent repeated inclusion
======================
According to # define and condition compilation # ifdef, # ifndef # else # The most common use of endif is to prevent repeated inclusion of header files.
However
# Pragma once
Better. Now GCC cl.exe supports not onlyCodeLess, and no macro name is required. It is better.
# Pragma description of compiler information // complex usage, refer to the http://baike.baidu.com/view/1451188.htm
# Warning display compilation warning information
# Error show compilation error information
Reminders under certain conditions can be provided during compilation of these conditions. For example, if the defined macro is not defined, # error is used to stop compilation.
Multiple conditions in Conditional compilation and multiple macros can be used to determine simultaneously
================================
Conditional compilation is also in progress, for example, determining the two conditions at the same time
# How should I write ifdef (A & B? If it is ifdef or ifndef, this cannot be written.
It must be written in the format of # If (A = 1 & B = 2. Try removing # define B 2, and the compilation information and output in the condition will not be displayed.
# Include <stdio. h># Include <Iostream> Using Namespace STD; Int Main ( Int Argc, Char ** Argv) {cout < " Main " < Endl; # Define A 1 # Define B 2// # Ifdef A & # ifdef B # If (A = 1 & B = 2) # Pragma Message ("\ npragma message Yes defined a B \ n ") Cout < " Yes defined a and B ?? " < Endl; # Endif Return 0 ;}
Ifdef can also be found to have multiple conditions:
similar to: # If defined _ debug | defined vld_force_enable
//As you can see in PWD. c In the source code (sf.net link) of Boost-jam-3.1.18, we have accumulated.//It seems that Cl also defines the NT variable. GNU gcc defines _ gnuc __/*Mingw on Windows declares path_max in limits. h*/# IfDefined (NT )&&! Defined (_ gnuc __)# Include<Direct. h># DefinePath_max _ max_path# Else# Include<Unistd. h># IfDefined (_ como __)# Include<Linux/limits. h># Endif# Endif
VLD is a programming toolkit for detecting memory leaks. Recommended! I don't know what to do if I encounter a segment error or the memory is not properly released. Use this. Segment errors do not seem to be able to be effectively detected .. Wild pointer!