簡體   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