<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/139957>139957</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Please add forward declaration in function prototypes
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
fefe17
</td>
</tr>
</table>
<pre>
A typical pattern in C code is to have a pointer and a length as separate function arguments.
For example: size_t strnlen(const char* string, size_t maxlen);
It would be awesome if we could tell the compiler that string is maxlen bytes long.
C99 has a method for doing that, but only if the length appears first in the list of arguments:
size_t strnlen2(size_t maxlen, char string[maxlen]);
gcc has an extension for the other case that I think would be a wonderful addition to clang, too:
size_t strnlen(size_t maxlen; char string[maxlen], size_t maxlen);
We add a forward declaration of maxlen to the argument list to tell the compiler that a maxlen argument is forthcoming.
Could you please add this to clang, too?
It would be much easier to get this feature through the language committee if both gcc and clang already supported it.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8lMGO4zYMhp9GvhAbOHKcxAcfMrMIsLfeeixombbUyqIh0ZNJn76QPWl2tzs9BaFF8uf3U8KU3BiIWlW_qPprgYtYju1AA-1PRcf9vb2A3Gdn0MOMIhQDuACvYLgncAmEweIbAcLMLghFwNADgqcwigVMkGjGiEIwLMGI4wAYx2WiIGmnysuVI9A7TrMnVV0gub_pD4EkMXgKSp8NhyRgLEalLznuwqj06-PghO_ruUZVL6q8qPLyTeDGi--hI8AbJZ4I3AA3ArOGhbwHsfnvNDtPEcSifFTOI20lobsLJfAcxizztWnAYgKEicRyDwNH6Dmn5PSsqFsEOPh77pbrPxDMM2FMMLiYJMNbv7kkwMMThaoum_wfAWilzz9N-rrCeJCoXz7i9dfvIYzGbHID0LtQSJl7lpybs1iKYDDRNvo3EOvCX99hgxuHnuKweMC-d6trwmA8bvCF-RPB_9FbvXyu939c_J1yZ8As-oaxh56Mz3uUpfDwMEl4neiBceOag782GR95_ya4lDuINTy5zels9grizgvMnjKmLEXstu4_Qrj-tHHTYiwQJpdbMowkW-JAKEvMwCMvo92WAMO44LiKnJwIrYvasVjI_uWLtDYD9JGwv0Na5pmjUA9OdkXfVn1TNVhQuz8dTro-7JtjYduyPu2rozk2hjSVhsq-G05VRdURKzzjqXCtLnVd1vuDLnW1P-4Iz6f6vO_OzXBujh2pQ0kTOr_z_m3acRwLl9JC7b5qmvpUeOzIp_XN0DrQDdavSuv8hMQ2J33pljGpQ5n9SM8y4sRT-9sT6q_cdeH5VMyRheU-UyqW6FsrMq9XRV-Vvo5O7NLtDE9KX3OPj58vc-Q_yYjS11VZUvr6If2t1f8EAAD__4Oys1c">