[man-pages] Question about the length notations in C library functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Alejandro,

I would like to ask a question about the length notations in many of
the C functions in the Linux man pages.

For example, in the synopsis section of mcstowcs(3):

    size_t mbstowcs(wchar_t dest[restrict .dsize], const char
*restrict src, size_t dsize);

What is the dot character before the `dsize` for?

When I tried to include this prototype verbatim in C code (C99 and
above), I got a compiler error. There is no dot allowed in the
notation like this.

Another error I got is that `dsize` is undeclared, because `dsize` is
an argument only declared _later_  in the prototype. So ultimately the
prototype only worked when the `dsize` token is commented out:

    size_t mbstowcs(wchar_t dest[restrict /* dsize */], const char
*restrict src, size_t dsize);

I personally like these length notations in the function synopses
because they give a quick view on how the length arguments are
applied. Except that the notations should compile, or else they could
draw more confusion.

And, as you mentioned something about the `_Countof` proposal in the
comment here
(https://github.com/llvm/llvm-project/issues/130429#issuecomment-2710310494),
I think it's also good to let you know, that the `dsize` in the
example above, doesn't compile (thus you have another language issue
to address). :)

(In case you didn't notice, I'm the same person who reported the
mbsnrtowcs(3) man page bug
(https://bugzilla.kernel.org/show_bug.cgi?id=219847), because I tried
implementing a version of mbsnrtowcs and mbsrtowcs just as a hobby. My
code can be seen here:
(https://gitlab.com/-/snippets/3718423))




[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux