o_wild Messages: 28 Registered: December 2008 Location: Urmqi
Promising Member
The following code is excerpt of an opensource software, but there is error when compiled.
fprintf(ofp,"%s\n",mes1); // mes1 is of type String
The error message is
cannot pass objects of non-trivially-copyable type 'class Upp::String' through '...'
The software can be compiled with both mingw and MSVC as the developer says. Since I have problem using MSVC due to C2001 error(new line in constant), I choose MingGW 4.5.0.
Is their any substitute for 'fprintf'? by the way, i tested 'printf' and found the same problem.
cbpporter Messages: 1400 Registered: September 2007
Ultimate Contributor
The problem is that when trying to pass your string as an argument ta a variable argument function the compiler has no means of knowing that you are trying to pass a C string. In such cases you must explicitly specify that you want to convert from String to C string. Try ~mes1, mes1.Begin() or casting to (char*).