0.2.3: bug fix extern length symbol

This commit is contained in:
Adam 2025-08-17 14:46:48 +01:00
parent 4d3f31cdc4
commit 484062b64a
4 changed files with 6 additions and 14 deletions

2
Cargo.lock generated
View File

@ -4,7 +4,7 @@ version = 4
[[package]]
name = "bin2hpp"
version = "0.2.2"
version = "0.2.3"
dependencies = [
"thiserror",
]

View File

@ -1,6 +1,6 @@
[package]
name = "bin2hpp"
version = "0.2.2"
version = "0.2.3"
authors = ["Adam Macdonald"]
edition = "2024"
license = "GPL-3.0-only"

View File

@ -27,9 +27,7 @@ OUTPUT OPTIONS:
--constexpr Whether the symbol should be marked as constexpr (C++ mode)
--symname NAME Symbol name
--namespace NAME Namespace in which the symbol will exist
(uses namespace example {} in C++ mode and prepends
EXAMPLE_ to symbol names in C mode)
--namespace NAME Namespace in which the symbol will exist (C++ mode)
--guard NAME Preprocessor macro to use for the header guard (#ifndef ...)
(default: derive from output filename)

View File

@ -62,6 +62,7 @@ pub fn with_contents(
with_definition(config, in_data, buf)?;
write!(buf, "#else{}", config.line_ending).unwrap();
with_includes(config, buf);
with_declaration(config, in_data, buf);
}
@ -205,21 +206,14 @@ pub fn with_declaration(config: &Config, in_data: &[u8], buf: &mut String) {
match config.container_type {
ContainerType::CArray(_) => {
write!(
buf,
"{}{};{}",
modifiers,
length_data_type_symbol(config),
config.line_ending
)
.unwrap();
write!(buf, "{}{};{}", modifiers, in_data.len(), config.line_ending).unwrap();
}
ContainerType::CString => {
write!(
buf,
"{}{};{}",
modifiers,
length_data_type_symbol(config),
in_data.len() + 1,
config.line_ending
)
.unwrap();