pyccel / pyccel-cuda

Cuda extension to pyccel
MIT License
1 stars 0 forks source link

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

Open smazouz42 opened 5 days ago

smazouz42 commented 5 days ago

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