<分区>
#pragma once
在编译我一直在处理的项目时无法正常工作。稍微阅读了该主题后,我发现使用它的一个缺点是如果同一个文件位于不同的位置,那么它不会像另一种使用 include guards 的方式那样工作:
#ifndef __SOMETHING_H__
#define __SOMETHING_H__
这里是错误:
../../engine/scene/../common/../bitsquid/queue.h:78:29: error: redefinition of ‘template<class T> void foundation::queue::reserve(foundation::Queue<T>&, uint32_t)’
../../engine/scene/../common/../bitsquid/queue.h:78:29: error: ‘template<class T> void foundation::queue::reserve(foundation::Queue<T>&, uint32_t)’ previously declared here
可以看到路径是一样的。我正在使用 g++ 来编译源代码。我通常会用其他风格的包含守卫替换它,但我想避免这种情况,因为我没有编写库。
gcc 版本是 4.6.3