diff --git a/lib/src/uuid.rs b/lib/src/uuid.rs index 43fffe97b..9dcd3797b 100644 --- a/lib/src/uuid.rs +++ b/lib/src/uuid.rs @@ -33,10 +33,9 @@ pub extern "C" fn tc_uuid_nil() -> TCUuid { Uuid::nil().into() } -/// Length, in bytes, of a C string containing a TCUuid. -// TODO: why not a const? -#[no_mangle] -pub static TC_UUID_STRING_BYTES: usize = ::uuid::adapter::Hyphenated::LENGTH; +// NOTE: this must be a simple constant so that cbindgen can evaluate it +/// Length, in bytes, of the string representation of a UUID (without NUL terminator) +pub const TC_UUID_STRING_BYTES: usize = 36; /// Write the string representation of a TCUuid into the given buffer, which must be /// at least TC_UUID_STRING_BYTES long. No NUL terminator is added. diff --git a/lib/taskchampion.h b/lib/taskchampion.h index a42060ac6..9c7c030b1 100644 --- a/lib/taskchampion.h +++ b/lib/taskchampion.h @@ -1,5 +1,11 @@ #include #include +#define TC_UUID_STRING_BYTES 36 + +/** + * Length, in bytes, of the string representation of a UUID (without NUL terminator) + */ +#define TC_UUID_STRING_BYTES 36 /** * A result combines a boolean success value with @@ -74,8 +80,6 @@ typedef struct TCUuid { extern "C" { #endif // __cplusplus -extern const size_t TC_UUID_STRING_BYTES; - /** * Create a new TCReplica with an in-memory database. The contents of the database will be * lost when it is freed.