GLM:不能再编译了

时间:2013-03-26 03:47:49

标签: c++ gcc compiler-errors clang glm-math

有人再使用this library吗?

去年为我工作很棒,但现在我的代码没有编译:

(在MinGW上使用GCC 4.6.1):

In file included from ../include/glm/./core/func_packing.hpp:190:0,
                 from ../include/glm/glm.hpp:103,
                 from SmoothRenderer.cpp:11:
../include/glm/./core/func_packing.inl: In function 'glm::detail::uint32 glm::packUnorm4x8(const glm::detail::tvec4<float>&)':
../include/glm/./core/func_packing.inl:84:17: error: expected primary-expression before '(' token
../include/glm/./core/func_packing.inl:84:17: error: expected primary-expression before ')' token
../include/glm/./core/func_packing.inl:84:17: error: expected ';' before 'round'
../include/glm/./core/func_packing.inl:85:26: error: 'D' was not declared in this scope
../include/glm/./core/func_packing.inl: In function 'glm::detail::tvec4<float> glm::unpackUnorm4x8(const uint32&)':
../include/glm/./core/func_packing.inl:94:38: warning: statement has no effect [-Wunused-value]
../include/glm/./core/func_packing.inl:99:4: error: 'D' was not declared in this scope

这是最新版本0.9.4.3。

我的Mac上的类似问题与最新的clang:

In file included from SmoothRenderer.cpp:10:
In file included from ../include/glm/glm.hpp:103:
In file included from ../include/glm/./core/func_packing.hpp:190:
../include/glm/core/func_packing.inl:84:33: error: expected '(' for function-style cast or type construction
                detail::uint8 D((detail::uint8)round(clamp(v.w, 0.0f, 1.0f) * 255.0f));
                                 ~~~~~~~~~~~~~^
./util.h:330:15: note: expanded from macro 'D'
# define D(x) x
              ^
In file included from SmoothRenderer.cpp:10:
In file included from ../include/glm/glm.hpp:103:
In file included from ../include/glm/./core/func_packing.hpp:190:
../include/glm/core/func_packing.inl:85:26: error: use of undeclared identifier 'D'
                return detail::uint32((D << 24) | (C << 16) | (B << 8) | A);
                                       ^
../include/glm/core/func_packing.inl:99:4: error: use of undeclared identifier 'D'
                        D * 1.0f / 255.0f);
                        ^
../include/glm/core/func_packing.inl:94:30: warning: expression result unused [-Wunused-value]
                detail::uint32 D((p >> 24) & Mask8);
                ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~
./util.h:330:15: note: expanded from macro 'D'
# define D(x) x
              ^
In file included from SmoothRenderer.cpp:10:
In file included from ../include/glm/glm.hpp:108:
In file included from ../include/glm/./core/func_noise.hpp:85:
../include/glm/core/func_noise.inl:125:33: error: too many arguments provided to function-like macro invocation
                detail::tvec4<T> const D(0.0, 0.5, 1.0, 2.0);
                                              ^
../include/glm/core/func_noise.inl:125:27: error: expected ';' at end of declaration
                detail::tvec4<T> const D(0.0, 0.5, 1.0, 2.0);
                                        ^
                                        ;

这是一个仅限标题的库。这样的事情不应该发生......

我只是将它用于一些4x4矩阵乘法和反演。由于我的应用程序的其余部分广泛使用LAPACK,所以我真的不需要glm。但我讨厌当我试图制作非常便携的代码随机打破这样的时候。

1 个答案:

答案 0 :(得分:2)

是的,结果是D宏的问题。该死的,在询问后4分钟回答我的问题。这是解释问题的美妙之处。有一半的时间足够了。

这是避免使用预处理器的另一个原因。疯狂的错误。虽然,值得赞扬的是,clang非常好,不仅可以提到某些东西看起来似乎与其他地方定义的宏,它甚至将它复制到那里向我展示。