From C’s Union to C++’s Variant: A Marvelous Journey of Type Safety Evolution

From C's Union to C++'s Variant: A Marvelous Journey of Type Safety Evolution

In the world of programming, we are always looking for safer and more elegant ways to express complex data structures. Today, let’s explore the union in C and the std::variant introduced in C++17, examining how they address similar problems in different eras, yet are fundamentally different. 🌟 Introduction: Why Do We Need Union Types? Imagine … Read more

Insights on ICC Ruling: Arbitration Case No. 23611/DDA

Insights on ICC Ruling: Arbitration Case No. 23611/DDA

By Wu Ying, Li Yu, Gong Yiduo, Zheng Junwei, Zhou Fangyuan, Tian Tong Law Firm This article contains12,021words, estimated reading time21minutes On January 1, 2019, the International Chamber of Commerce (ICC) International Court of Arbitration proposed in its “Guidelines for Parties and Arbitral Tribunals on Participation in Arbitration Under the ICC Arbitration Rules” (“ICC Guidelines”) … Read more

A Comprehensive Guide to C Language Unions: Memory Reuse, Bit Manipulation, and Type Punning!

A Comprehensive Guide to C Language Unions: Memory Reuse, Bit Manipulation, and Type Punning!

Scan the code to follow Chip Dynamics and say goodbye to “chip” congestion! Search WeChatChip Dynamics Dear “brick movers” of C language, today we will discuss something exciting—unions. If a structure (Struct) is a “luxury apartment” where each member has its own independent room, then a union is definitely a “shared rental house” where all … Read more

The Twin Brother of Structures: Learn C Language Unions in 3 Minutes

The Twin Brother of Structures: Learn C Language Unions in 3 Minutes

Regarding the questions left at the end of the previous article on structures in C language, I have completed the explanation and published it on Bilibili. If you are interested, you can take a look. Here is the link:https://www.bilibili.com/video/BV1tSYDzoEmd?vd_source=abed82db08f64a03325f5e43fb10c5ec What exactly is a union? A union, also known as a variant record, is a special … Read more

Comprehensive Analysis of Union Memory Layout: Perfect Mapping from C Language to Python ctypes

Comprehensive Analysis of Union Memory Layout: Perfect Mapping from C Language to Python ctypes

1. Core Features and Memory Layout Principles of Union A union is a special data structure in C language, characterized by all members sharing the same memory space, with the size determined by the largest member. This design allows unions to achieve type punning through memory reuse, playing an irreplaceable role in scenarios such as … Read more

Unions in C Language: Techniques for Memory Savings

Unions in C Language: Techniques for Memory Savings

Unions in C Language: Techniques for Memory Savings In the C language, a union is a special data structure that allows storing different types of data in the same memory location. Unlike structures, which allocate independent memory for each member, a union only allocates enough space for its largest member. This makes unions an effective … Read more

Detailed Explanation of Unions and Enumerations in C Language

Detailed Explanation of Unions and Enumerations in C Language

Detailed Explanation of Unions and Enumerations in C Language In the C language, unions and enumerations are two important data structures. They each have unique uses and characteristics that help programmers manage data more efficiently. This article will provide a detailed introduction to these two data structures, along with code examples to deepen understanding. 1. … Read more

The Concept of Union and Its Application in Embedded Programming

The Concept of Union and Its Application in Embedded Programming

The author has limited ability, and if there are any errors in the article, I would greatly appreciate it if friends could point them out. Thank you! Concept of Union In Chinese, a union is also referred to as a “共用体” (union), “联合” (joint), or “联合体” (joint body). Its definition format is the same as … Read more

Applications of Unions in Microcontroller Programming

Applications of Unions in Microcontroller Programming

01Union In the previous article “Combining Enumerations and Structures”, it was mentioned that a structure is like a packaging that encapsulates variables with common characteristics. A structure is a composite or complex type that can contain multiple members of different types. In C language, there is another syntax that is very similar to structures, called … Read more