加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

error C2338: You've instantiated std::aligned_storag

发布时间:2020-12-16 07:18:33 所属栏目:百科 来源:网络整理
导读:? ? 报的完整错误为: error C2338: You‘ve instantiated std::aligned_storageLen,Align with an extended alignment (in other words,Align alignof(max_align_t)). Before VS 2017 15.8,the member type would non-conformingly have an alignment of on

?

?

报的完整错误为:

error C2338: You‘ve instantiated std::aligned_storage<Len,Align> with an extended alignment (in other words,Align > alignof(max_align_t)). 
Before VS 2017 15.8,the member type would non-conformingly have an alignment of only alignof(max_align_t). 
VS 2017 15.8 was fixed to handle this correctly,but the fix inherently changes layout and breaks binary compatibility (*only* for uses of 
aligned_storage with extended alignments). Please define either (1) _ENABLE_EXTENDED_ALIGNED_STORAGE to acknowledge that you understand this 
message and that you actually want a type with an extended alignment,or (2) _DISABLE_EXTENDED_ALIGNED_STORAGE to silence this message and 
get the old non-conformant behavior.

  

?

  

大概意思就是:VS2017 15.8版本修复了老版本有关对齐存储部分缺陷,但修复本身也有缺陷。如果不想编译时报这个问题,就在预编译时定义一个宏 _ENABLE_EXTENDED_ALIGNED_STORAGE 或者 _DISABLE_EXTENDED_ALIGNED_STORAGE(博主的理解是按照修复后的逻辑处理就定义带enable那个,按照老版本的逻辑处理就定义带disable那个)

参考解决方法:

打开 项目属性页 -- > C/C++? --> Preprocessor -->?Preprocessor Definitions

里面添加,_DISABLE_EXTENDED_ALIGNED_STORAGE

即可。

?

?

?

?

?

?

参考文章

error C2338: You‘ve instantiated std::aligned_storage《Len,Align》 with an extended alignment.(讨论)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读