From 484062b64ac755bf0580f0e393e25d02386745b9 Mon Sep 17 00:00:00 2001 From: "adam@2khz.xyz" Date: Sun, 17 Aug 2025 14:46:48 +0100 Subject: [PATCH] 0.2.3: bug fix extern length symbol --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/constants.rs | 4 +--- src/generate.rs | 12 +++--------- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4a1cd60..3d442d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 4 [[package]] name = "bin2hpp" -version = "0.2.2" +version = "0.2.3" dependencies = [ "thiserror", ] diff --git a/Cargo.toml b/Cargo.toml index 3e35866..77604a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/constants.rs b/src/constants.rs index 5dff3f4..ed0e870 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -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) diff --git a/src/generate.rs b/src/generate.rs index fa09146..b8ae5aa 100644 --- a/src/generate.rs +++ b/src/generate.rs @@ -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();