当我包含 <algorithm> 时命名空间 "manufacturing"

Namespace "manufacturing" when I include <algorithm>

我有一个让我发疯的命名空间问题。这里有一个名为 "Utility" 的命名空间,由另一位程序员编写,我在我的一些代码中使用了它。一个文件只会给我带来问题。这个文件包括<算法>,我必须拥有它。我已经尝试了各种重新排列和其他随机的东西来尝试摆脱它。我一辈子都弄不明白为什么 stl_algo.h 有这个问题。

/usr/include/c++/4.6/bits/stl_algo.h: In function ‘void std::random_shuffle(_RAIter, _RAIter)’:
/usr/include/c++/4.6/bits/stl_algo.h:5152:40: error: ‘std::Utility’ has not been declared

在包含 <algorithm>.

之前,必须有一个名称为 randiter_swap 的宏定义

要解决此问题,请尝试在包含其他 headers 之前包含 <algorithm> 或执行以下操作:

#undef rand
#undef iter_swap
#include <algorithm>

我可以reproduce the exact error, line numbers, positions and all

#include <cstdlib>
#define rand Utility::rand
#include <algorithm>

产生

In file included from /usr/local/gcc-4.6.4/lib/gcc/x86_64-unknown-linux-gnu/4.6.4/../../../../include/c++/4.6.4/algorithm:63:0,
                 from prog.cc:3:
/usr/local/gcc-4.6.4/lib/gcc/x86_64-unknown-linux-gnu/4.6.4/../../../../include/c++/4.6.4/bits/stl_algo.h: In function 'void std::random_shuffle(_RAIter, _RAIter)':
/usr/local/gcc-4.6.4/lib/gcc/x86_64-unknown-linux-gnu/4.6.4/../../../../include/c++/4.6.4/bits/stl_algo.h:5152:40: error: 'std::Utility' has not been declared

因此,请检查您的 headers 并寻找 #define'ing rand 的东西。狠狠地揍这个骇人听闻的黑客的负责人,然后删除 #define.