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

fmt/print: add 64-bit length modifier %Li, %Ld and %Lu #905

Merged
merged 2 commits into from
Aug 30, 2023
Merged

Conversation

sreimers
Copy link
Member

@sreimers sreimers commented Aug 11, 2023

With normal printf you have to use something like this:

#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

int main()
{
    uint64_t t = 1;
    
    printf("Value %" PRIu64 "\n", t);

    return 0;
}

Since uint64_t can be unsigned long int -> %lu or unsigned long long int -> %llu on 32-bit wordsize plattforms.

This PR introduces %L to handle this:

#include <re.h>

int main()
{
    uint64_t t = 1;
    
    re_printf("Value %Lu\n", t);

    return 0;
}

@sreimers sreimers marked this pull request as ready for review August 11, 2023 13:04
@sreimers sreimers closed this Aug 13, 2023
@sreimers sreimers reopened this Aug 30, 2023
@sreimers sreimers merged commit 36b80da into main Aug 30, 2023
@sreimers sreimers deleted the int64_t_printf branch August 30, 2023 15:24
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.

1 participant