-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat][struct_pack][struct_json] support struct bit-field #595
Comments
目前还没有支持,是可以支持的,等后面支持好了再更新这个issue。 |
需要修改反射机制,目前struct_json的反射机制需要通过宏注册结构体的成员指针,但是位域并没有成员指针…… |
同样,位域字段也不能返回引用。可能需要使用生成getter/setter函数的反射手段才能支持位域。 |
也许可以增加一个位域类型来实现这个功能,比如
你觉得这样如何?@queshishuai |
这个没法压缩空间吧 |
json 化应该不在乎这个空间吧,在乎的是最终的文本内容吧。@queshishuai |
那为何要使用位域呢,直接用int不就好了 |
也许是已有的结构呢?可以把这个场景再说说。@queshishuai |
那不都是要改结构体的定义,如果不支持位域的话。 |
还有个办法是增加一个宏来指定哪些字段是位域,办法总是有的。 |
核心问题是,位域没有成员指针也不能转换为引用。必须使用getter/setter |
针对位域的结构体要特殊处理,确实很麻烦。 |
对的,是已有的结构体,不希望改变包含位域的结构体,结构体很大,手动改不现实。需求的场景就是方便将现有结构体(不能改变结构体)序列化为 json。 |
不希望手动改变结构体,这样工作量太大了 |
Hey there! Support of bit fields is planned for now or not in queue? Interesting becouse i have up once similar issue yet. |
It's hard to support bit field, we dont have plan now. Maybe later I will consider support it by marco. |
example:
The text was updated successfully, but these errors were encountered: