http://www.bobarcher.org/software/include/index.html
節錄翻譯:
為避免重複include,須加上include guard。
以下為internal include guard
File "myheader.hpp"
#ifndef MYHEADER_HPP
#define MYHEADER_HPP
// Contents of include file go here
#endif
但上面的方法用在非常大的project時,會造成compile的時間增加。
This point is made by John Lakos in his book "Large Scale C++ Software Design", and is used as an argument to support the following idiom:
File "myheader2.hpp"
#ifndef MYHEADER_HPP
#include "myheader.hpp"
#endif
// Rest of header file goes here
...
=====================================================================http://en.wikipedia.org/wiki/Include_guard
http://ccckmit.wikidot.com/cp:includeguard
沒有留言:
張貼留言