julienbarnoin,
@julienbarnoin@mastodon.gamedev.place avatar

All this time I've been using the return value of snprintf as the number of characters actually written, when it's in fact the number of characters that would be written if the max size passed in were large enough.

In fact: "If the resulting string would be longer than n-1 characters, the remaining characters are discarded and not stored, but counted for the value returned by the function."

BRB, got a bunch of files to go back over... 😓

#c

gfxstrand,
@gfxstrand@mastodon.gamedev.place avatar

@julienbarnoin Be careful! The behavior on Windows is different. 🤦🏻‍♀️

julienbarnoin,
@julienbarnoin@mastodon.gamedev.place avatar

@gfxstrand Oh boy... now you have me worried 😬

gfxstrand,
@gfxstrand@mastodon.gamedev.place avatar

@julienbarnoin Yeah, IIRC Windows just returns -1 if there's an overflow.

julienbarnoin,
@julienbarnoin@mastodon.gamedev.place avatar

@gfxstrand Good to know, will definitely be checking that.
Of course to be sure I should check the behaviour on Windows 11, Windows 10... Windows 8.1, Windows 8... Windows XP, 2000... Windows Me, no just kidding on that last one.

julienbarnoin,
@julienbarnoin@mastodon.gamedev.place avatar

@gfxstrand This programming thing was supposed to be easy, 25 years on I still can't do it properly 😑

  • All
  • Subscribed
  • Moderated
  • Favorites
  • cpp
  • slotface
  • kavyap
  • thenastyranch
  • everett
  • tacticalgear
  • rosin
  • Durango
  • DreamBathrooms
  • mdbf
  • magazineikmin
  • InstantRegret
  • Youngstown
  • khanakhh
  • ethstaker
  • JUstTest
  • ngwrru68w68
  • cisconetworking
  • modclub
  • tester
  • osvaldo12
  • cubers
  • GTA5RPClips
  • normalnudes
  • Leos
  • provamag3
  • anitta
  • megavids
  • lostlight
  • All magazines