This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How should vwprintf() work?


[Petter Reinholdtsen]
> Based on this failure claim on
> <URL:http://www.dinkumware.com/conform_c.html>, I started looking on
> how vwprintf() work.
> 
>   - If L"" is passed as the format parameter to vwprintf a negative
>     value is returned, indicating an error occurred.
> 

[Jakub Jelinek]
> No, that's correct behaviour.
> See e.g. ISO C99, 7.19.2:

Hm.  Then I'm not sure how to test the failure claim.  Can I freopen()
stdout?

Or perhaps I should just use the wprintf() all the way, like this:

  % cat x.c
  #include <stdio.h>
  #include <wchar.h>
  #include <stdarg.h>
  int main()
  {
    va_list args;
    int i;
  #if defined(TEST)
    wprintf(L"started\n");
  #endif /* TEST */
    i = vwprintf(L"", args);
    wprintf(L"retval: %d\n", i);
    wprintf(L"ended\n");
    return 0;
  }
  % cc -Wall -W -ansi x.c ; ./a.out
  x.c: In function `main':
  x.c:11: warning: implicit declaration of function `vwprintf'
  x.c:12: warning: implicit declaration of function `wprintf'
  retval: 0
  ended
  % cc -DTEST -Wall -W -ansi x.c ; ./a.out
  x.c: In function `main':
  x.c:9: warning: implicit declaration of function `wprintf'
  x.c:11: warning: implicit declaration of function `vwprintf'
  started
  retval: 0
  ended
  %

But this obviously work.  I must be testing the wrong thing, or
perhaps the test code used by Dikumware is testing something else?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]