Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

byteorder functions in capital letters? #5959

Closed
kaspar030 opened this issue Oct 17, 2016 · 15 comments
Closed

byteorder functions in capital letters? #5959

kaspar030 opened this issue Oct 17, 2016 · 15 comments
Assignees
Labels
Type: question The issue poses a question regarding usage of RIOT

Comments

@kaspar030
Copy link
Contributor

RIOT's byteorder.h defines NTOHL() as capital static inline functions. Does anyone remember the reason for not using ntohl() et al?

Like this it is really inconvenient for code also used on other platforms (see kaspar030/sock#2).

@kaspar030 kaspar030 added the Type: question The issue poses a question regarding usage of RIOT label Oct 17, 2016
@miri64
Copy link
Member

miri64 commented Oct 18, 2016

@kaspar030 I guess because our coding conventions state that macros should be upper case. For portability you can find the POSIX naming in sys/posix/include/sys/bytes.h ;-)

@miri64
Copy link
Member

miri64 commented Oct 18, 2016

(which also should help you with portability since the macro is exactly where other OSs would expect it to be <sys/bytes.h>)

@kaspar030
Copy link
Contributor Author

I guess because our coding conventions state that macros should be upper case.

Well, that's the thing. They are static inline functions, not macros.

@miri64
Copy link
Member

miri64 commented Oct 18, 2016

See #4812

@kaspar030
Copy link
Contributor Author

So with the current state of byteorder.h, you don't remember the reason for the function names being uppercase?

@miri64
Copy link
Member

miri64 commented Oct 18, 2016

Not really, but I guess the HTONS etc. wrapper macros are primarily there for legacy reasons. @Kijewski?

@kaspar030
Copy link
Contributor Author

the HTONS etc. wrapper macros

They're not macros. :)

@miri64
Copy link
Member

miri64 commented Oct 18, 2016

That's even more confusing ^^.

@jnohlgard
Copy link
Member

jnohlgard commented Oct 18, 2016 via email

@kaspar030
Copy link
Contributor Author

I would propose then, independently of #4812, to change them to use lowercase names. #4812 can then implement the functions using the const macros (or builtins...), and the posix wrapper can just include byteorder.h. What do you think?

@miri64
Copy link
Member

miri64 commented Oct 18, 2016

Fine by me.

@OlegHahm
Copy link
Member

I would suspected that non-RIOT code rather expects these functions to be macros and thus to be uppercase.

@kaspar030
Copy link
Contributor Author

I would suspected that non-RIOT code rather expects these functions to be macros and thus to be uppercase.

Just checked, in my system headers they are declared as functions.

@OlegHahm
Copy link
Member

True.

@miri64
Copy link
Member

miri64 commented Apr 13, 2017

According to the POSIX-specification they are functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: question The issue poses a question regarding usage of RIOT
Projects
None yet
Development

No branches or pull requests

5 participants