This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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: [PATCH,RFC] Change __convert_from_v to use snprintf and use it



> However, I'm a bit nervous about this: what if _GLIBCPP_USE_C99 becomes true but in fact
> snprintf is /not/ C99-conforming? In fact, I'm aware of pre-C99 snprintf which returned -1 in
> case of too small buffer. This would be really bad.

Then you can make a more elaborate test as part of configure. (See the 
AC_TRY_COMPILE or the AC_TRY_RUN type tests.)

Don't worry about this detail at the moment: it won't change your code, 
only the configure-related bits.

> Is it safe to assume that if _GLIBCPP_USE_C99 is defined then the libc is C99 conforming and
> therefore snprintf will behave correctly at run time? (vs the -1 problem, I mean)

Yes. It's possible to construct a configure test that insures your 
assumption is valid.

> In my tree __convert_from_v is now tentatively as below. Notice the dummy if(__size); to
> silence warnings about an unused parameter in case !C99. What do you suggest about this? Is
> there a much cleaner way to solve the trouble with __size when !C99 ???

...., const int __size __attribute__((__unused__)), ....

-benjamin


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