英文:
How can I make cbindgen not include stdlib.h?
问题
我正在一个嵌入式项目中使用自定义的libc。我尝试将Rust集成到项目中,但不允许包含stdlib.h。我正在使用cbindgen生成Rust库的头文件,我想知道如何使其不包括libc?
英文:
I am working in an embedded project using a custom libc. I am trying to integrate Rust into the project and I am not allowed to include the stdlib.h, I am using cbindgen to generate the header file for the rust library and I would like to know how can I make it not include the libc?
答案1
得分: 2
创建一个cbindgen.toml文件,并在其中设置以下内容:
# 是否应禁止cbindgen的默认C/C++标准导入。这些导入通常包含在默认情况下,因为我们生成的头文件通常需要它们(例如uint32_t)。当前生成的导入包括:
# * 对于C: <stdarg.h>,<stdbool.h>,<stdint.h>,<stdlib.h>,<uchar.h>
# * 对于C++: <cstdarg>,<cstdint>,<cstdlib>,<new>,<cassert>(取决于配置)
# 默认值:false
no_includes = true
更多信息请查看:https://github.com/mozilla/cbindgen/blob/master/docs.md.
英文:
Create a cbindgen.toml file and set in it:
# Whether cbindgen's default C/C++ standard imports should be suppressed. These
# imports are included by default because our generated headers tend to require
# them (e.g. for uint32_t). Currently, the generated imports are:
#
# * for C: <stdarg.h>, <stdbool.h>, <stdint.h>, <stdlib.h>, <uchar.h>
#
# * for C++: <cstdarg>, <cstdint>, <cstdlib>, <new>, <cassert> (depending on config)
#
# default: false
no_includes = true
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论