0

有人再使用这个库吗?

去年对我来说很好,但现在我的代码没有编译:

(在带有 GCC 4.6.1 的 MinGW 上):

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 做任何事情。但是我讨厌当我尝试使非常便携的代码像这样随机中断时。

4

1 回答 1

2

是的,原来是D宏的问题。该死的,问了4分钟后回答了我的问题。这就是解释问题的美妙之处。一半的时间就足够了。

这是避免使用预处理器的另一个原因。疯狂的错误。虽然,值得称赞的是,clang 非常好,不仅提到在其他地方定义的宏似乎有问题,它甚至将它复制到那里给我看。

于 2013-03-26T03:53:04.803 回答