Skip to content

Use %ls format specifier for README example - #469

Closed
endolith wants to merge 1 commit into
libusb:masterfrom
endolith:patch-1
Closed

endolith wants to merge 1 commit into
libusb:masterfrom
endolith:patch-1

Conversation

@endolith

Copy link
Copy Markdown
Contributor

I finally got it running, but it was printing only the first character. %ls is for wide strings and works.

https://devblogs.microsoft.com/oldnewthing/20190830-00/?p=102823

"If you want your code to work both on runtimes that use the Windows classic printf rules as well as those that use C standard printf rules, you can limit yourself to %hs for narrow strings and %ls for wide strings, and you’ll get consistent results regardless of whether the format string was passed to sprintf or wsprintf."

It was printing only the first character.

https://devblogs.microsoft.com/oldnewthing/20190830-00/?p=102823

"If you want your code to work both on runtimes that use the Windows
classic printf rules as well as those that use C standard printf rules,
you can limit yourself to %hs for narrow strings and %ls for wide
strings, and you’ll get consistent results regardless of whether the
format string was passed to sprintf or wsprintf."

@Youw Youw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@endolith

Copy link
Copy Markdown
Contributor Author

(It probably should exit when hid_open returns NULL, also, or it produces SIGSEGV when the device isn't plugged in. Confusing for beginners like me.)

@endolith

Copy link
Copy Markdown
Contributor Author

@Youw

Youw commented Oct 20, 2022

Copy link
Copy Markdown
Member

I guess for beginners the hidtest would be a better sample and it was updated/improved over time a lot.

I you want to improve sample in the README (e.g. replace wprintf with printf as it is used in hidtest) - you're very welcome to do so.

@endolith

Copy link
Copy Markdown
Contributor Author

@Youw Yeah, I'm just new to this and not sure of the conventions, but I'll try.

@Youw Youw closed this in #470 Oct 21, 2022
@endolith
endolith deleted the patch-1 branch October 21, 2022 11:42
@endolith
endolith restored the patch-1 branch October 21, 2022 11:42
@endolith
endolith deleted the patch-1 branch October 21, 2022 11:42
@mcuee mcuee added the documentation Improvements or additions to documentation label Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants