import core.stdc.stdint;

alias sds = char*;

struct sdshdr5 { ubyte flags; // 3 lsb of type, and 5 msb of string length char[] buf; }

struct sdshdr8 { uint8 len; // used uint8 alloc; // excluding the header and null terminator ubyte flags; // 3 lsb of type, 5 unused bits char[] buf; }

struct sdshdr16 { uint16 len; // used uint16 alloc; // excluding the header and null terminator ubyte flags; // 3 lsb of type, 5 unused bits char[] buf; }

struct sdshdr32 { uint32 len; // used uint32 alloc; // excluding the header and null terminator ubyte flags; // 3 lsb of type, 5 unused bits char[] buf; }

struct sdshdr64 { uint64 len; // used uint64 alloc; // excluding the header and null terminator ubyte flags; // 3 lsb of type, 5 unused bits char[] buf;

请将以下c语言代码转为d语言betterc模式代码typedef char sds; Note sdshdr5 is never used we just access the flags byte directly However is here to document the layout of type 5 SDS strings struct __attribute__ __packed

原文地址: https://www.cveoy.top/t/topic/gvGp 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录