Timeline for Implementation of C Standard Library Function ntohl()
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 13, 2016 at 21:33 | history | edited | Roland Illig | CC BY-SA 3.0 |
added 1 character in body
|
Dec 13, 2016 at 13:36 | comment | added | Peter - Reinstate Monica |
@DavidBowling The ntohl which comes with your compiler is most likely a compiler built-in or comes with the system library for the specific target CPU designed to squeeze out the last bit of performance, i.e. it will not be a function, and it will not be portable, and it will not be C. Some drivers may rely on that performance. It will specifically be not even a NOP for big endian machines. If you strive for portable code, however, @Matthieu has said it all in his answer.
|
|
Dec 13, 2016 at 10:55 | comment | added | ad absurdum |
As I mentioned in the question, I only check for little-endian byte order, which is why I used uint16_t . Does the library version of ntohl() check for PDP-endianness? What about other middle-endian schemes?
|
|
Dec 13, 2016 at 10:52 | comment | added | ad absurdum | Thanks for the comments. I am still getting used to inclusion guards, and I guess I did not really need one here. I think that the only place I ever use lowercase ells in identifiers is with hexadecimal literals, and this is to set the suffix off from the digits. But it always makes me wince a little, and this is a style point that I have not settled for myself yet. | |
Dec 13, 2016 at 8:07 | history | edited | Roland Illig | CC BY-SA 3.0 |
added 1 character in body
|
Dec 13, 2016 at 8:02 | history | answered | Roland Illig | CC BY-SA 3.0 |