Skip to content

Consider adding CString/*const i8 literals #18065

Closed
@canndrew

Description

@canndrew

There's already b"foo" syntax for [u8] literals and I've seen talk of adding s"foo" for String literals (perhaps through a syntax extension). If we're going down that path we could also add c"foo" syntax which could be either a CString or a *const i8. This would be useful for interacting with foreign C code. Currently, to call a C function with a string constant I'm using

foo(b"my string\0".as_ptr() as *const i8)

But that's a little cumbersome (and error-prone if I accidentally leave the NUL off).

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions