Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Add helper for creating CharSlice from a string literal #36

Merged
merged 4 commits into from
Mar 21, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ddprof-ffi/cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ style = "both"
no_includes = true
sys_includes = ["stdbool.h", "stddef.h", "stdint.h"]

after_includes = """

#define ddprof_ffi_CharSlice_from_literal(string) \\
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any objection to DDPROF_FFI_CHARSLICE_C instead? It's shorter, in upper-case like macros should be, and uses the _C convention which is used in standard macros for integer literals eg INT64_C(1000000000000).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went ahead and pushed a commit. If you object, feel free to revert. I was just trying to speed up the speculative happy path.

/* NOTE: Compilation fails if you pass in a char* instead of a literal */ ((ddprof_ffi_CharSlice) {.ptr = "" string, .len = sizeof(string) - 1})"""

[export]
prefix = "ddprof_ffi_"

Expand Down