Python
Java
PHP
IOS
Android
Nodejs
JavaScript
Html5
Windows
Ubuntu
Linux
联合内位域的对齐
我对以下代码如何在内存中布局感到有点困惑 struct Thing union unsigned value 24 uint8 t bytes 3 Thing int v value v void foo printf Thing p va
c
gcc
unions
bitfields
memorylayout
union 可以模板化吗?
似乎联合可以在 c 11 中模板化 它们用于例如std Optional 的参考实现 https github com akrzemi1 Optional blob master optional hpp 在 c 11 之前这可能吗 是的
c
templates
unions
联合中的字符串、段错误
这基本上是一个标记联合 include
c
segmentationfault
c14
unions
用于从 H/W 寄存器读取的位字段
我想从32位寄存器中读取第2位 第5位和第6位 我决定使用结构位字段来存储它们 下面的数据结构正确吗 struct readData int unwanted 1 int reqbit1 1 int unwanted1 2 int reqb
c
BitManipulation
bitwiseoperators
unions
bitfields
联合和结构初始化
我偶然发现了一段基于 C 语言联合的代码 代码如下 union struct char ax 2 char ab 2 s struct int a int b st u 12 1 printf d d u st a u st b 我只是不明
c
unions
C++ 和 C 中的联合初始化
我已经构建了一个工作 C 库 它使用常量 在头文件中定义为 typedef struct Y union struct bit field bits uint8 t raw 4 X CardInfo static const CardInf
c
initialization
unions
c03
您可以将一名工会成员的值分配给另一名工会成员吗?
考虑以下代码片段 union int a float b a b a is this UB b b something 将一名工会成员分配给另一名工会成员是否有效 不幸的是 我相信这个问题的答案是 尽管自赋值完全没问题 但 C 中对联合的操
c
memory
languagelawyer
unions
联合中的标量成员是否计入公共初始序列?
In the union U下面 如果a or b是活动成员 是否定义了访问行为c struct A int a struct B int a double b union U A a B b int c In 类 联盟 https tim
c
languagelawyer
C17
unions
TypeScript 中关联对象数组的接口
我有一个像这样的对象 var obj key1 apple key2 true key3 123 key n So obj可以包含任意数量的命名键 但值必须全部是字符串 布尔值或数字 我如何声明类型obj作为 TypeScript 中的接口
typescript
tuples
associativearray
unions
gcc、严格别名和通过联合进行转换
你有什么恐怖故事要讲吗 GCC 手册最近添加了有关 fstrict aliasing 和通过联合强制转换指针的警告 获取地址 转换结果指针并取消引用结果未定义的行为 强调 即使强制转换使用联合类型 例如 union a union int
c
gcc
typeconversion
unions
strictaliasing
允许多个不同形状的接口作为 TypeScript 返回类型
我有一个函数 它接受一些参数并生成将传递到外部进程的对象 由于我无法控制最终需要创建的形状 因此我必须能够为我的函数采用一些不同的参数并将它们组装成适当的对象 这是一个非常基本的示例 展示了我遇到的问题 interface T1A type
typescript
interface
unions
typeguards
在 C 中使用位域的正确方法是什么?
我正在使用位字段来轻松访问我正在尝试为没有 FPU 的微控制器制作的浮点库 问题是我似乎无法使其与位字段一起使用 看一看 typedef struct union unsigned long mantissa 23 unsigned lon
c
bitfields
unions
C 中的位域,其结构包含结构体的并集
嗯 为什么我打印的时候会这样sizeof struct MyStruct 该代码输出 3 而不是 2 pragma pack push 1 struct MyStruct unsigned char a 6 union struct uns
c
struct
unions
bitfields
uint32_t 和 uint8_t[4] 未定义行为的联合? [复制]
这个问题在这里已经有答案了 在评论中这个答案 https stackoverflow com a 8568531 1025391据说使用如下联合将整数分割成字节将是未定义的行为 该位置给出的代码与此相似但不完全相同 如果我更改了代码的未定义
c
unions
strictaliasing
typepunning
C++11 是否允许非匿名联合包含静态数据成员?
在 C 11 中 我声明以下联合 union U4 char c int i static int si 当我使用 std c 11 pedantic errors 使用 g 4 7 0 编译此代码时 出现以下错误 经过少量编辑 错误 本地
c
C11
staticmembers
unions
C# 中的联合:结构成员似乎没有对齐
我定义了以下结构来模拟 C 联合 最终将用于 C 互操作 StructLayout LayoutKind Sequential internal struct STRUCT1 public Guid guid public String s
c
struct
unions
该结构的初始序列是什么?
我遇到了最初的序列概念 通过标准搜索initial sequence短语只给出 3 个结果 并且没有给出定义 Section N3797 9 5 1 class union 如果标准布局联合包含多个标准布局结构 有着共同点的初始序列 9 2
c
struct
languagelawyer
unions
共同的初始序列和比对
在思考反例时这个问题 https stackoverflow com q 21499120 420683 我想出了 struct A alignas 2 char byte 但如果这是合法和标准布局 它的布局是否与此兼容struct B s
c
C11
unions
memoryalignment
standardlayout
C++11 具有重要成员的匿名联合
我正在更新我的一个结构 我想向其中添加一个 std string 成员 原始结构如下所示 struct Value uint64 t lastUpdated union uint64 t ui int64 t i float f bool
c
C11
constructor
unions
anonymousclass
更改常量表达式中联合的活动成员
和谁玩constexpr and union我发现我无法更改某个活动的活跃成员union in constexpr 只有一个例外 union空类 constexpr bool t struct A struct B union U A a
c
c14
unions
constexpr
Variant
«
1
2
3
4
5
6
»