Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
wxString::Printf()
Balazs:
If printfs work, there is no reason to change.
Also, as a Hungarian, I can tell, that most often the whole sentence needs to be restructured often to get a meaningful translation, and with <<, this is impossible.
Besides, what would be the advantages of <<? Is it a 100-times faster or what? :roll:
--
Greets,
B.
Game_Ender:
--- Quote from: Balazs on June 10, 2006, 02:58:07 pm ---Besides, what would be the advantages of <<? Is it a 100-times faster or what? :roll:
--- End quote ---
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. So the << operator makes this a compile time check instead of a run time crash. I am not sure if wxString::printf, does the same. I do know that Boost format allows printf like syntax with the same type safety and still giving you the translation benifits. You can also add the << operator to your classes so you just do "cout << MyClassInstance;".
Balazs:
--- Quote ---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.
--- End quote ---
GCC checks for this at compile time.
And how do you solve translation?
sethjackson:
--- Quote from: Balazs on June 10, 2006, 07:11:59 pm ---
--- Quote ---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.
--- End quote ---
GCC checks for this at compile time.
--- End quote ---
Can you show me please?
Ceniza:
--- Code: (cpp) ---#include <stdio.h>
int main()
{
printf("%s %d %g", 1, 2);
return 0;
}
--- End code ---
--- Quote from: gcc -Wall test.c -o test.exe ---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
--- End quote ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version