2 ms·
The solution to this is as old as salt: typedef int seconds; and time.sleep(seconds duration);
by xyzzy_plugh 5y ago
The solution to this is as old as salt:
typedef int seconds;
and
time.sleep(seconds duration);
- ameliaquining 5y agoThat doesn't really seem better, because the fact that the unit is seconds is only obvious if you happen to be looking at the function signature in the header or somesuch. This is because C typedefs are type aliases, not newtypes. If seconds were instead a struct with a single int field, or something like that, then that would help a little. To really solve this problem, you need information hiding, which C doesn't have except through questionable hacks.