Re: parameterized translation strings; what is the solution?



I don't think it is entirely true
that it isn't typesafe, by the way. I mean, there aren't (can't be)
proper type checks, of course, but e.g. newer versions gcc/g++ will in
fact issue a warning if there is a mismatch between the format and the
arguments.


A purist would say, "Never, ever use a function with variable argument lists."

Any variable arguments function is not typesafe. As you said yourself,
there can't be any type checks at compile time - hence, no type
safety. gcc/g++ will indeed warn about printf formats because it has
explicit knowledge about them. Remember that the printf/scanf family
of functions with their variable arguments are a large source of
errors in pure C. They're fertile ground for buffer overruns and other
Bad Things (TM). This is probably what motivated the compiler guys to
make special exceptions for specific functions.

I'd still recommend using one of the C++ string libraries to do your
composition.

Paul



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]