Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(bufix) debug_printf macros don't escape '{' and '}' correctly. #166

Closed
wants to merge 0 commits into from

Conversation

FractalFir
Copy link
Contributor

The debug_printf and debug_printfln passes its format string to the asm! macro, which uses { and } to separate its arguments. Passing { and } to asm! directly is incorrect, and leads to compilation issues:

error: invalid asm template string: expected `'}'`, found `'"'`
     --> examples/shaders/sky-shader/src/lib.rs:13016:2
      |
13015 | unsafe{debug_printf!("Variant3{")};
      |        -------------------------- in this macro invocation
13016 |         unsafe{debug_printf!("fld0:")};
      | ----^ expected `'}'` in asm template string
      | |
      | because of this opening brace
      |
      = note: if you intended to print `{`, you can escape it using `{{`
      = note: this error originates in the macro `debug_printf` (in Nightly builds, run with -Z macro-backtrace for more info)

This commit escapes those characters using {{ and }}, which removes this issue and produces correct behaviour.

Copy link
Collaborator

@LegNeato LegNeato left a comment

Choose a reason for hiding this comment

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

Thanks! I was just looking at this code, likely needs a major revamp in the future.

@LegNeato
Copy link
Collaborator

LegNeato commented Dec 2, 2024

The commit is over in #167 now and I'll land it. Not sure what screwed up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants