繁体   English   中英

什么是 __attribute__((__bounded__(__string__,2,3)))?

[英]what is __attribute__((__bounded__(__string__,2,3)))?

我是 openbsd bcrypt代码,在下面的代码片段中收到未知属性的警告:

void SHA256Update(SHA2_CTX *, const void *, size_t)
__attribute__((__bounded__(__string__,2,3)));

我试图用谷歌搜索有界的属性,但没有找到相关结果。 我想将该代码移植到不同的平台,如果我得到有界属性的含义,我想使用该平台的类似属性。

任何建议将不胜感激!

The __bounded__ attribute is available in the context of function declarations to enable to determine the length of the memory region pointed by one of the function arguments using the value of another of it's arguments; 第一个参数稍微改变了不同styles功能的检查类型。

在这种情况下,它将第二个参数的类型增加到 function 的类型,长度由第三个参数指定; __string__绑定样式还检查 size 参数不是来自应用于指针的sizeof ,因为您想要目标的大小。

它仅在 OpenBSD 的 GCC 分支中可用(参见man 1 gcc-local ); 还有一个短命的 GNU C 扩展(介于 2000 年和 2003 年之间),名称相同,目的相同,它是一个直接类型限定符,可以在 function 声明之外使用,但是,AFAIK 也没有记录。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM