【问题标题】:Bullet physics source code not building in x86 - wrong preprocessor directives in Visual Studio 2017子弹物理源代码未在 x86 中构建 - Visual Studio 2017 中的预处理器指令错误
【发布时间】:2017-12-16 07:47:52
【问题描述】:

我正在尝试构建 Bullet Physics 源代码。他们的 cmake 东西都不起作用,所以我只是将 Bullet 源文件直接复制到我的 Visual Studio 项目中并直接构建它。但是,只会构建 64 位版本。当我尝试构建 32 位时,它给出了一堆以“E2474 user-defined literal operator not found”开头的错误——这似乎来自 btScalar.h 中 btAssert 的定义

我的项目必须缺少一些预处理器指令或设置或其他东西。如果有人可以查看这些定义并查看我的 Visual Studio 2017 项目中需要更改哪些设置,那就太棒了。请告诉我,谢谢。

项目链接: https://github.com/mister51213/BulletSetupTest/tree/master/BulletPhysicsTest1

代码:

#ifdef BT_DEBUG
    #ifdef _MSC_VER
        #include <stdio.h>
        #define btAssert(x) { if(!(x)){printf("Assert "__FILE__ ":%u ("#x")\n", __LINE__);__debugbreak();   }}
        //#define btAssert(x)

    #else//_MSC_VER
        #include <assert.h>
        #define btAssert assert
    #endif//_MSC_VER
#else
        #define btAssert(x)
        //#define btAssert(x) { if(!(x)){printf("Assert "__FILE__ ":%u ("#x")\n", __LINE__);__debugbreak(); }}

#endif
        //btFullAssert is optional, slows down a lot
        #define btFullAssert(x)

        #define btLikely(_c)  _c
        #define btUnlikely(_c) _c
#else

【问题讨论】:

    标签: c++ visual-studio visual-studio-2017 assert preprocessor-directive


    【解决方案1】:

    在字符串文字和下一个元素之间没有空格的宏扩展,例如

    "Assert "__FILE__
    

    user-defined literals 的规则遇到问题,它保留了这种格式。

    这在 C++11 中已经发生了。

    简单的解决方案是在字符串文字和下一个元素之间添加一个空格:

    "Assert "  __FILE__
    ---------^
    

    更多示例见http://en.cppreference.com/w/cpp/language/user_literal#Notes

    【讨论】:

      猜你喜欢
      • 2014-01-09
      • 2012-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-01
      • 2017-08-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多