g++ 是否支持scalar_storage_order?
Does g++ support scalar_storage_order?
g++支持sclar_storage_order
吗?
我已经在 g++6 和 g++7 中测试过它,但它只是发出警告,没有正确处理它。
源代码:
#ifdef __cplusplus
#include <cstdio>
#include <cstdint>
#else
#include <stdio.h>
#include <stdint.h>
#endif
typedef struct {
uint32_t a;
uint16_t b;
} __attribute__((scalar_storage_order("big-endian"))) SS;
int main(int argc, char *argv[]) {
uint8_t raw[] = { 0xaa, 0xbb, 0xcc, 0xdd, 0x11, 0x22 };
SS* instance = (SS*)raw;
printf("%x, %xn", instance->a, instance->b);
return 0;
}
输出:
gcc-6 source.c && ./a.out
aabbccdd, 1122
g++-6 source.cpp && ./a.out
source.cpp:16:53: warning: ‘scalar_storage_order’ attribute ignored [-Wattributes]
} __attribute__((scalar_storage_order("big-endian"))) SS;
^
ddccbbaa, 2211
发布了C++前端的补丁,但在合并之前在分支上恢复了补丁:
------------------------------------------------------------------------
r229934 | ebotcazou | 2015-11-07 19:10:36 +0100 (Sat, 07 Nov 2015) | 8 lines
c-family/
* c-common.c (handle_scalar_storage_order_attribute): Accept attribute
in place in C but not in C++.
testsuite/
* c-c++-common/sso-[1-7].c: Move to...
* gcc.dg/sso-[2-8].c: ...here.
* g++.dg/sso-[2-8].C: ... and here.
合并的修补程序为 C 和 C++ 注册#pragma scalar_storage_order
处理程序,但C++前端未更改为处理由编译指示控制的内部global_sso
标志,因此目前在 g++ 中没有任何对此功能的支持。
相关文章:
- Ascending order c++
- 如何处理Boost Spirit X3导致Visual Studio 2019 "static initialization order fiasco"?
- Azure Storage CPP & VCPKG
- C++应用程序缺少 winrt::Windows::Storage::Streams::D ataWriter
- thread_local "storage class specified"
- C++ 结构数组 - "This declaration has no storage class or type specifier"
- "static initialization order fiasco"是 constexpr 变量的问题吗?
- 在使用 In Order 遍历成员函数时引发异常(堆栈溢出)时出现问题
- C++ 中的"this declaration has no storage class or type specifier"错误
- 如何修复派生类给出错误'declaration has no storage class or type specifier'?
- "declaration has no storage class or type specifier" C++
- 为什么在与静态库链接时强制执行 order(例如 source.cxx -lstatic)
- "The order of evaluation of expressions is left to right."是什么意思
- 如何编译C 代码,包括Google Cloud Storage库
- memory_order_seq_cst操作的"happens before"关系和"precedes in a single total order"关系有什么区别?
- C /WRL项目未知名称空间Windows :: Storage
- std::shared_ptr::owner_before 和 std::owner_less:"owner-based order"到底是什么意思?
- Marmalade Core Storage (s3eSecureStoragePut & s3eSecureStorageGet) not persisting
- 从 Windows::Storage::Streams::IBuffer 中获取字节数组
- 错误"this declaration has no storage class or type specifier"