Printf bit me

< 1 Minute Read.

Work­ing on an Un­re­al En­gine 4 project, I had a strage is­sue with their FString::Printf(format, args...) func­tion (which is ba­si­cal­ly just call­ing _vsntprintf).

The fi­nal is­sue was that I was try­ing to build a SQL query along the lines of INSERT INTO Table(a, b, c) VALUES(%d, %d, %d), in­to which I would then for­mat in the val­ues. The val­ue for b was a 64bit in­te­ger val­ue, though, which on An­droid caused the pa­ram­e­ter to leak over in­to the next, be­cause I was not for­mat­ting it as a long (“%lld”), but as an in­te­ger (“%d”).

I learnt the painful way and am hap­py that it “on­ly” cost me two hours.

Writ­ten in 5 min­utes, ed­it­ed in 5 min­utes.