This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS: How to print unsigned long long (uint64_t ) using System_printf() and System_flush()

Tool/software: Code Composer Studio

Respected sir/ madam,

            I am trying to print  data of type unsigned long long (uint64_t ). But it is printing some random constant value even if i change data. I have used %d , %ld, %lld and %llu  for printing but none of  those work. So please tell me how to print data of type  unsigned long long (uint64_t )  using   System_printf()  and   System_flush() .    

  • Can you supply some code as to what you tried?

    You can always punt by using a union and printing the individual bytes (though that is not portable).
  • hi,

       I tried following

       System_printf(" data read is:-%d\n", rdata );     

          System_flush();

       System_printf(" data read is:-%ld\n", rdata );     

          System_flush();

       System_printf(" data read is:-%llu\n", rdata );     

          System_flush();

    regards,

    Digvijay

  • digvijay khambe said:
    So please tell me how to print data of type  unsigned long long (uint64_t )  using   System_printf()  and   System_flush() .    

    System_printf is documented as:

    This function behaves much like the ANSI C Standard printf but does not support the full range of format strings specified by the C Standard.

    The ll (long long) length modifier is not supported by System_printf.

    A work-around is to use a sprintf style function to format a string with 64-bit values, and the string is then output the strinf with System_printf. E.g. the following code which used in a SYS/BIOS project for a Cortex A15:

        Bits64 total_rx_bytes = 0;
        Bits64 total_tx_bytes = 0;
        char summary_text[128];
    
        snprintf (summary_text, sizeof (summary_text),
                "tcpWorker stop clientfd=0x%x errno=%d total_rx_bytes=%llu total_tx_bytes=%llu\n",
                clientfd, fdError (), total_rx_bytes, total_tx_bytes);
        System_printf("%s", summary_text);
        System_flush ();