Anonymous struct/union in C

本文探讨了Renesas C编译器在处理无名结构体的共用体时的限制,并提供了两种可能的解决方案:采用C++编译C代码或通过智能化代码编辑器批量替换代码。
Anonymous struct/union in C
2010年11月26日
  Renesas的C编译器,不接受类似与windows中
  LARGE_INTEGER的共用体。
  也就是说:编译器C语言编译,
  共用体中不可以有无名的结构体。
  这是ms的扩展。
  union LARGE_INTEGER {
  struct {
  DWORD lowpart;
  LONG highpart;
  };
  LONGLONG quadpart;
  };
  问题:如果现在有大量的C语言代码这样用,
  怎样做改动最小?
  1. C++编译C代码。
  2. 改动union,然后用智能化的代码编辑器来批量替换。
  gcc 可以用-fms-extensions
  既然是扩展,想移植就不应该用。
  gcc 的说明:
  http://gcc.gnu.org/ml/gcc-patches/1999-06n/msg0037 6.html
  http://www.mailinglistarchive.com/xcode-users@list s.apple.com/msg03872.html
struct page { 75 unsigned long flags; /* Atomic flags, some possibly 76 * updated asynchronously */ 77 /* 78 * Five words (20/40 bytes) are available in this union. 79 * WARNING: bit 0 of the first word is used for PageTail(). That 80 * means the other users of this union MUST NOT use the bit to 81 * avoid collision and false-positive PageTail(). 82 */ 83 union { 84 struct { /* Page cache and anonymous pages */ 85 /** 86 * @lru: Pageout list, eg. active_list protected by 87 * lruvec->lru_lock. Sometimes used as a generic list 88 * by the page owner. 89 */ 90 union { 91 struct list_head lru; 92 93 /* Or, for the Unevictable "LRU list" slot */ 94 struct { 95 /* Always even, to negate PageTail */ 96 void *__filler; 97 /* Count page's or folio's mlocks */ 98 unsigned int mlock_count; 99 }; 100 101 /* Or, free page */ 102 struct list_head buddy_list; 103 struct list_head pcp_list; 104 }; 105 /* See page-flags.h for PAGE_MAPPING_FLAGS */ 106 struct address_space *mapping; 107 pgoff_t index; /* Our offset within mapping. */ 108 /** 109 * @private: Mapping-private opaque data. 110 * Usually used for buffer_heads if PagePrivate. 111 * Used for swp_entry_t if PageSwapCache. 112 * Indicates order in the buddy system if PageBuddy. 113 */ 114 unsigned long private; 115 }; 116 struct { /* page_pool used by netstack */ 117 /** 118 * @pp_magic: magic value to avoid recycling non 119 * page_pool allocated pages. 120 */ 121 unsigned long pp_magic; 122 struct page_pool *pp; 123 unsigned long _pp_mapping_pad; 124 unsigned long dma_addr; 125 union { 126 /** 127 * dma_addr_upper: might require a 64-bit 128 * value on 32-bit architectures. 129 */ 130 unsigned long dma_addr_upper; 131 /** 132 * For frag page support, not supported in 133 * 32-bit architectures with 64-bit DMA. 134 */ 135 atomic_long_t pp_frag_count; 136 }; 137 };这段代码是有关透明大页的数据结构吗
最新发布
09-12
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值