#1 swprintf at json.c

closed
nobody
None
5
2007-07-03
2007-06-29
No

In file "json.c", function "json_escape_string" (or "json_escape_to_ascii" in last SVN version), I see the following line:
swprintf (temp, 7, L"\\u%.4x\t", text[i]);
which causes a compiler warning "passing arg 2 of `swprintf' makes pointer from integer without a cast".

May be "snwpintf" was supposed to be here?

Discussion

  • Anonymous - 2007-07-03

    Logged In: YES
    user_id=1518475
    Originator: NO

    It appears that the swprintf() function is declared as:

    int swprintf(wchar_t *s, size_t n, const wchar_t *format, ...);

    You can see the function reference at:
    http://www.opengroup.org/pubs/online/7908799/xsh/swprintf.html

    That code compiles without any warning or error with GCC 4.1.2 with the following flags set: -Wall -Wextra -std=c99.

    On the other hand, it seems that at least in Microsoft Visual Studio 2003 that function does not have the size_t parameter. What compiler are you using?

     
  • Anonymous - 2007-07-03

    Logged In: YES
    user_id=1518475
    Originator: NO

    After a bit of digging I found out that, according to the C99 standards, the swprintf() function should indeed be declared as:

    int swprintf(wchar_t *s, size_t n, const wchar_t *format, ...);

    So it seems that the source of your problem is that your compiler doesn't comply with the C99 standards.

    Hope this helps

     
  • Anonymous - 2007-07-03
    • status: open --> closed
     

Log in to post a comment.