<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><div><div style="font-family: Calibri,sans-serif; font-size: 11pt;">Tools like SonarQube can raise a "warning" for comments started with "TODO:" or "FIXME:". Wouldn't it be more interesting if those could be presented as warnings instead of using #warning? And this could be an optional setting as commented would not influence compilation.<br><br></div></div><div dir="ltr"><hr><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">From: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:swift-evolution@swift.org">Will Stanton via swift-evolution</a></span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Sent: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;">‎29/‎05/‎2016 07:09 PM</span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">To: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:harlan@harlanhaskins.com">Harlan Haskins</a></span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Cc: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:swift-evolution@swift.org">swift-evolution</a></span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Subject: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;">Re: [swift-evolution] [Pitch] #warning</span><br><br></div>+1 to #warning or optionally(?) emitting something like TODO: more visibly!<br><br>In past ObjC projects, I have used #warning to confirm the right macros were enabled.<br><br>I often (1) work around differences between the iOS simulator and device with TARGET_IPHONE_SIMULATOR (+similar) and (2) change API endpoints among sandbox, production, etc… (which may not relate to whether the open project is debug/release)<br>For instance, I have code like:<br>#if TARGET_IPHONE_SIMULATOR || API_DEBUG<br>[Declarations]<br>#warning DEBUG API: Do not release<br>#else<br>[Different declarations]<br>#endif<br><br>I check that release builds do not emit a “warning Do not release” before submitting/deploying.<br><br><br>I think it would be great if (1) lines/branches of Swift source with #warning or something like INDICATE: are highlighted and (2) FIXMEs, TODOs, warnings, etc… are emitted and put into the Issues Navigator of Xcode.<br><br>In the past, both of the above (line highlighting and the ease of checking the Issues Navigator for “warning: Do not release” in Xcode) were conducive to my sanity:<br>Issue highlighting from the last build seems more reliable than syntax highlighting. Xcode syntax highlighting colors (1) sometimes goes down (I’ve encountered SourceKit crashes pretty often) or (2) is wrong (perhaps macros weren’t detected correctly).<br>Also, while (3) using schemes and (4) seeing the -Doptions in the build command are useful, they are less visible by themselves.<br><br>Regards,<br>Will Stanton<br><br>&gt; On May 29, 2016, at 4:20 PM, Chris Lattner via swift-evolution &lt;swift-evolution@swift.org&gt; wrote:<br>&gt; <br>&gt; As to #warning, Swift’s use of warnings are significant different than the use in C. In C compilers, many of the warnings produced *should* be errors, but can’t be because that effects language conformance and could break a large body of code. Swift doesn’t have this problem, so it treats warnings as “things that should be addressed before you commit your patch, but shouldn’t block a build if (e.g.) you’re in the middle of a big refactoring”.&nbsp; For example, an unused variables is a warning in Swift.<br>&gt; <br>&gt; This difference in policy is what makes me question where #warning makes sense for Swift.&nbsp; OTOH, errors in Swift are used in exactly the same way as in C compilers, which is why bringing #error forward makes sense to me.<br><br>_______________________________________________<br>swift-evolution mailing list<br>swift-evolution@swift.org<br>https://lists.swift.org/mailman/listinfo/swift-evolution<br></body></html>