So are there any major disadvantages to using <<?
Yes, somehow the operator<< didn't worked ok with integers, eventrough the documentation says otherwise.
1. _("Welcome %s to %s (build %d).");
2. << _("Welcome ") << s << _(" to ") << s2 << _(" (build ") << i << _(").");
So are there any major disadvantages to using <<?Yes, somehow the operator<< didn't worked ok with integers, eventrough the documentation says otherwise.
Exactly. In unicode builds, streaming integers to wxString resulted to nothing :shock: . I don't know if it has been fixed in the current wx version but we wouldn't go back and change everything now.
Another reason is translations. E.g.:CodeIn many languages a word's translation might differ based on context. In the second case, there is no context (each string would be translated separately).1. _("Welcome %s to %s (build %d).");
2. << _("Welcome ") << s << _(" to ") << s2 << _(" (build ") << i << _(").");
Which is easier for the translators? ;)
Besides, what would be the advantages of <<? Is it a 100-times faster or what? :roll:
The standard C printf is not type safe and you can crash your program by telling printf you are giving it one kind of variable and passing it another.GCC checks for this at compile time.
QuoteThe standard C printf is not type safe and you can crash your program by telling printf you are giving it one kind of variable and passing it another.GCC checks for this at compile time.
#include <stdio.h>
int main()
{
printf("%s %d %g", 1, 2);
return 0;
}
test.c: In function `main':
test.c:5: warning: format argument is not a pointer (arg 2)
test.c:5: warning: too few arguments for format
Code: cpp#include <stdio.h>
int main()
{
printf("%s %d %g", 1, 2);
return 0;
}Quote from: gcc -Wall test.c -o test.exetest.c: In function `main':
test.c:5: warning: format argument is not a pointer (arg 2)
test.c:5: warning: too few arguments for format
It works for gcc builtin variadic functions, such as [fs]?(print|scan)f, and it does confirmedly not work with wxString::Printf - we have seen it crash and burn many times in the past.