<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 6, 2016, at 6:50 PM, 哀殿 via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><p style="margin: 0px 0px 9px; line-height: 24px;" class=""><!--StartFragment-->Hello Swift community,</p><p style="margin: 0px 0px 9px; line-height: 24px;" class="">I found  `__attribute__((sentinel(0,1)))` at <a href="https://github.com/apple/swift-clang/blob/c52d85ede49adaec457400697b1d4c1b7ea12881/test/Analysis/variadic-method-types.m#L46" class="">https://github.com/apple/swift-clang/blob/c52d85ede49adaec457400697b1d4c1b7ea12881/test/Analysis/variadic-method-types.m#L46</a>.</p><p style="margin: 0px 0px 9px; line-height: 24px;" class="">But I can't imagine how different it is from the `__attribute__((sentinel))`.</p><p style="margin: 0px 0px 9px; line-height: 24px;" class="">So,why we need `__attribute__((sentinel(0,1)))`?</p></div></div></blockquote></div><div>This is unrelated to Swift. That file is in clang; it's a test of clang's static analyzer.</div><br class=""><div class="">__attribute__((sentinel)) is identical to __attribute__((sentinel(0, 0))). The difference between sentinel(n, 0) and sentinel(n, 1) has to do with the handling of the last named parameter before the variadic arguments.&nbsp;</div><div class="">(n, 0) means the last named parameter is not part of the null-terminated list; the required sentinel must come after the last named parameter.&nbsp;</div><div class="">(n, 1) means the last named parameter is part of the null-terminated list; passing null to the last named parameter will satisfy -Wsentinel.</div><div class="">n is the number of non-null arguments that must follow the null sentinel. This is used for functions like execle() which passes envp after the null at the end of argv.</div><div class=""><br class=""></div><div class="">--&nbsp;</div><div class="">Greg Parker &nbsp; &nbsp; <a href="mailto:gparker@apple.com" class="">gparker@apple.com</a>&nbsp; &nbsp; &nbsp;Runtime Wrangler</div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>