On Sun, 12 Dec 2021, Martin Storsjö wrote:
On Sun, 12 Dec 2021, Biswapriyo Nath wrote:
2. The declarations in WinSDK have const parameters but glibc does
not. Which is the correct one?
Not sure offhand - let me study it and get back to you.
The const-ness that you're referring to is irrelevant.
If you have a pure function declaration (as opposed to a definition of an
inline function), there's no difference whatsoever between
void func(int param);
and
void func(const int param);
As the function receives a copy of the value of the integer argument, its
constness (within the function) doesn't matter to the caller.
As for an inline function like this,
static inline void func(const int param) { use_the_value_of(param); }
the constness only matters within the inline function itself (i.e. that
the parameter variable can't be changed).
Now when it comes to pointer parameters, such as
static inline int timespec_get(struct timespec *const _Ts, ...)
the constness only means that the pointer variable can't be changed to
point at a different address, within the function. But the function is
allowed to change the struct that the pointer points at.
So therefore, the two occurrances of const that you refer to, are
irrelevant.
I did a couple minor tweaks to your patch and tested it; I'll post my
version to the list.
// Martin
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public