首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >构建LLVM时,AlignOf.h中出现了错误

构建LLVM时,AlignOf.h中出现了错误
EN

Stack Overflow用户
提问于 2017-03-10 14:27:27
回答 1查看 162关注 0票数 0

我在使用cmake和Visual 14 2015从官方源文件构建LLVM时得到了多个错误,并且不知道为什么会发生这些错误,这些错误产生的原因是什么?

D:\LLVM\build\llvm\include\llvm/Support/AlignOf.h(57):error C2988:无法识别的模板声明/定义D:\LLVM\build\build\lib\System\LLVMSystem.vcxproj D:\LLVM\build\llvm\include\llvm/Support/AlignOf.h(57):错误C2059:语法错误:“D:\LLVM\build\build\lib\System\LLVMSystem.vcxproj D:\LLVM\build\llvm\include\llvm/Support/AlignOf.h(59):错误C2143:语法错误:缺失”;‘在'}’D:\LLVM\build\build\lib\System\LLVMSystem.vcxproj

这是AlignOf.h文件中的代码:

代码语言:javascript
复制
#ifndef LLVM_SUPPORT_ALIGNOF_H
#define LLVM_SUPPORT_ALIGNOF_H

namespace llvm {

template <typename T>
struct AlignmentCalcImpl {
  char x;
  T t;
private:
  AlignmentCalcImpl() {} // Never instantiate.
};

/// AlignOf - A templated class that contains an enum value representing
///  the alignment of the template argument.  For example,
///  AlignOf<int>::Alignment represents the alignment of type "int".  The
///  alignment calculated is the minimum alignment, and not necessarily
///  the "desired" alignment returned by GCC's __alignof__ (for example).  Note
///  that because the alignment is an enum value, it can be used as a
///  compile-time constant (e.g., for template instantiation).
template <typename T>
struct AlignOf {
  enum { Alignment =
         static_cast<unsigned int>(sizeof(AlignmentCalcImpl<T>) - sizeof(T)) };

  enum { Alignment_GreaterEqual_2Bytes = Alignment >= 2 ? 1 : 0 };
  enum { Alignment_GreaterEqual_4Bytes = Alignment >= 4 ? 1 : 0 };
  enum { Alignment_GreaterEqual_8Bytes = Alignment >= 8 ? 1 : 0 };
  enum { Alignment_GreaterEqual_16Bytes = Alignment >= 16 ? 1 : 0 };

  enum { Alignment_LessEqual_2Bytes = Alignment <= 2 ? 1 : 0 };
  enum { Alignment_LessEqual_4Bytes = Alignment <= 4 ? 1 : 0 };
  enum { Alignment_LessEqual_8Bytes = Alignment <= 8 ? 1 : 0 };
  enum { Alignment_LessEqual_16Bytes = Alignment <= 16 ? 1 : 0 };

};

/// alignof - A templated function that returns the mininum alignment of
///  of a type.  This provides no extra functionality beyond the AlignOf
///  class besides some cosmetic cleanliness.  Example usage:
///  alignof<int>() returns the alignment of an int.
template <typename T>
static inline unsigned alignof() { return AlignOf<T>::Alignment; }

} // end namespace llvm
#endif 
EN

回答 1

Stack Overflow用户

发布于 2020-09-24 07:02:47

我认为这主要是由于头文件中的对齐和alignof不一致所致。

这解决了我的问题:http://llvm.org/viewvc/llvm-project?view=revision&revision=117774

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42720728

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档