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

Invalid Suffix on Literal with PRId64 in C++11 #62

Open
smazouz42 opened this issue Jun 28, 2024 · 0 comments
Open

Invalid Suffix on Literal with PRId64 in C++11 #62

smazouz42 opened this issue Jun 28, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@smazouz42
Copy link

Describe the bug

When compiling C/C++ code using nvcc or any C++11-compliant compiler, a warning may appear due to the usage of the PRId64 macro in printf statements. The warning:

To Reproduce

Provide code to reproduce the behavior:
test.py

a = 10
print(a)

test.cu

#include "test.h"
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <inttypes.h>
#include <stdbool.h>

int64_t a;
bool initialised;

/*........................................*/
void test__init(void)
{
    if (!initialised)
    {
        a = INT64_C(10);
        printf("%"PRId64"\n", a);
        initialised = 1;
    }
}
/*........................................*/

Error details

Provide the generated code, or the error message:

/home/said/Desktop/pyccel/__pyccel__/test.cu:17:16: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
   17 |         printf("%"PRId64"\n", a);

Expected behavior

This warning is triggered because C++11 requires a space between the % literal and the PRId64 macro in format strings.
A clear and concise description of what you expected to happen.

Language

cuda

@smazouz42 smazouz42 added the bug Something isn't working label Jun 28, 2024
@smazouz42 smazouz42 changed the title Invalid Suffix on Literal with PRId64 in C++11 Fix Invalid Suffix on Literal with PRId64 in C++11 Jun 28, 2024
@smazouz42 smazouz42 changed the title Fix Invalid Suffix on Literal with PRId64 in C++11 Invalid Suffix on Literal with PRId64 in C++11 Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant