原文:
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#The__define_Guard

旨在防止multiple inclusion的問題,當然使用#pragma once預處理指令也可以得到相同的效果,但是#pragma once是compiler related;而#define Guard是所有compiler都可以使用。

為了保證#define Guard不會重覆,#define Guard由該header file的full path所組成。

Google定義#define Guard的格式為:

<PROJECT>_<PATH>_<FILE>_H_

創作者介紹
創作者 打字猴 的頭像
coherence

打字猴

coherence 發表在 痞客邦 留言(0) 人氣( 46 )