T
Tom Carroll
When assigning or testing equality between a type and a constant,
should the constant be casted to the type?
I.e.
should fork() == -1 be written as fork() == (pid_t)-1?
should uid = 45 be written as uid = (uid_t)45?
Is the casting necessary? Does it increase portability? Browsing
some projects, I noticed that -1 is casted but not other values, i.e.
chown("somefile", 45, (gid_t)-1).
In short, what is the best practice.
TIA
-Tom
should the constant be casted to the type?
I.e.
should fork() == -1 be written as fork() == (pid_t)-1?
should uid = 45 be written as uid = (uid_t)45?
Is the casting necessary? Does it increase portability? Browsing
some projects, I noticed that -1 is casted but not other values, i.e.
chown("somefile", 45, (gid_t)-1).
In short, what is the best practice.
TIA
-Tom