in reply to Re^2: [OT(C)] float parameter treated as double by callee -- but it fails with FFI
in thread [OT(C)] float parameter treated as double by callee -- but it fails with FFI

That's why there's no printf length modifier for char, float or double.

signed char c = 123; int i = 123; float f = 123; double d = 123; printf("%d\n", i); // ok printf("%d\n", c); // ok, even though %d expects int. printf("%f\n", d); // ok printf("%f\n", f); // ok, even though %f expects double.

(Not sure why there's one for short since they are guaranteed to be no larger than an int and unsigned int respectively.)

Seeking work! You can reach me at ikegami@adaelis.com

Replies are listed 'Best First'.
Re^4: [OT(C)] float parameter treated as double by callee -- but it fails with FFI
by ikegami (Pope) on Jul 01, 2021 at 23:42 UTC

    There is one for char (hh).

    The reason it and the one for short (h) exists is purely for symmetry with scanf (which needs to know the type of object at the provided address).

    Seeking work! You can reach me at ikegami@adaelis.com