I think this is because the C preprocessor will interpret SITUATIONALL not as a value but as an expression. That means your C code at that spot will be turned into “(SITUATION1 | SITUATION2 | etc)” and not into the result of that expression directly.<br><br>The clang importer could probably figure this out, but I suspect there are diminishing returns in figuring out what really is a constant as opposed to another expression etc. Especially in this example, the inconvenience of defining your own SITUATIONALL in Swift is likely lower than the inconvenience of that where the macro expression imports incorrectly and does unexpected things.<br><br>Please (anyone) correct me if I’m wrong here though, I’d like to know the definitive answer myself.<br><br>- Geordie<br><br><div class="gmail_quote"><div dir="ltr">Li Keqing via swift-users <<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>> schrieb am So. 17. Dez. 2017 um 13:08:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space">Here are some macros in C headers such as<div><br><div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(120,73,42);background-color:rgb(255,255,255)">#define SITUATION1 <span style="color:#272ad8">0x00000001</span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(120,73,42);background-color:rgb(255,255,255)">#define SITUATION1 <span style="color:#272ad8">0x00000002</span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(120,73,42);background-color:rgb(255,255,255)">#define SITUATION3 <span style="color:#272ad8">0x00000004</span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(120,73,42);background-color:rgb(255,255,255)">#define SITUATION4 <span style="color:#272ad8">0x00000008</span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(120,73,42);background-color:rgb(255,255,255)">#define SITUATIONALL (SITUATION1 | SITUATION2 | SITUATION3 | SITUATION4)</div></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(120,73,42);background-color:rgb(255,255,255)"><br></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(120,73,42);background-color:rgb(255,255,255)"><span style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px">when use these value in swift</span></div></div><div style="margin:0px;font-stretch:normal;line-height:normal;background-color:rgb(255,255,255)">those lines are okay</div><div style="margin:0px;font-stretch:normal;line-height:normal;background-color:rgb(255,255,255)"><div style="color:rgb(0,0,0);font-family:Menlo;font-size:11px;margin:0px;font-stretch:normal;line-height:normal"><span style="color:#ba2da2">let</span> value1 = <span style="color:#4f8187">SITUATION1</span></div><div style="color:rgb(0,0,0);font-family:Menlo;font-size:11px;margin:0px;font-stretch:normal;line-height:normal"><span style="color:#ba2da2">let</span> value2 = <span style="color:#4f8187">SITUATION2</span></div><div style="color:rgb(0,0,0);font-family:Menlo;font-size:11px;margin:0px;font-stretch:normal;line-height:normal"><span style="color:#ba2da2">let</span> value3 = <span style="color:#4f8187">SITUATION3</span></div><div style="color:rgb(0,0,0);font-family:Menlo;font-size:11px;margin:0px;font-stretch:normal;line-height:normal"><span style="color:#ba2da2">let</span> value4 = <span style="color:#4f8187">SITUATION4</span></div><div style="margin:0px;font-stretch:normal;line-height:normal">but this line would show error</div><div style="color:rgb(0,0,0);font-family:Menlo;font-size:11px;margin:0px;font-stretch:normal;line-height:normal"><span style="color:#ba2da2">let</span> valueAll = <span style="text-decoration:underline">S</span>ITUATIONALL</div><div style="color:rgb(0,0,0);font-family:Menlo;font-size:11px;margin:0px;font-stretch:normal;line-height:normal"><br></div><div style="color:rgb(0,0,0);font-family:Menlo;font-size:11px;margin:0px;font-stretch:normal;line-height:normal"><span style="font-family:Helvetica;font-size:12px"> Is it a bug ? or just be designed as it?</span></div></div></div>_______________________________________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br>
</blockquote></div>