【问题标题】:error : conflicting declaration for uint32_t [closed]错误:uint32_t 的声明冲突 [关闭]
【发布时间】:2014-05-24 04:59:56
【问题描述】:

当我第一次尝试编译我的程序时,我得到了这个错误:

错误:“uint32_t”没有命名类型

然后我包括

#include <stdint.h>

现在发现这个错误:

/include/stdint.h:52: 错误:声明冲突'typedef unsigned int uint32_t'

/cuda/include/vector_types.h:452: 错误:‘uint32_t’之前的声明为‘typedef struct uint32_t uint32_t’

有什么建议可以解决这个问题吗?谢谢

【问题讨论】:

  • 据我所知,我的任何 cuda 构建都不会发生这种情况。我可以包含stdint.h 和/或直接使用uint32_t 而不会出现问题。所以我怀疑你没有告诉我们你的环境。也许您应该提供一个简短的小程序来演示该问题,然后提供您用于编译的确切命令行以及您的机器配置(操作系统、CUDA 版本等)
  • @clouddy,请将其中一个答案标记为正确。我会推荐前两个答案中的任何一个。

标签: c++ cuda typedef uint32 uint32-t


【解决方案1】:

试试#include &lt;cstdint&gt; 和std::uint32_t。

【讨论】:

    【解决方案2】:

    这可以帮上忙吗?

    也许#include cstdint,但这可能并不总是有效或尝试

    #if defined __UINT32_MAX__ or UINT32_MAX
      #include <inttypes.h>
      #else
      typedef unsigned char uint8_t;
      typedef unsigned short uint16_t;
      typedef unsigned long uint32_t;
      typedef unsigned long long uint64_t;
      #endif
    

    【讨论】:

    • 我之前试过这个,但也没有成功。
    • 这种事情只有在你使用的编译器不符合标准时才需要(这当然可能适用于 nvcc!)
    【解决方案3】:

    您可以检查 uint32_t 是如何在 vector_types.h 中定义的,也许已经存在一些 #ifndef 内容,您只需重新排序包含即可摆脱。我通过谷歌找到了this 版本,但根本没有 uint32_t 声明。

    【讨论】:

      猜你喜欢
      • 2012-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-30
      • 1970-01-01
      • 2021-08-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多