Add a comment about ATTRIBUTE_UNUSED to avoid further confusion over when to
authorChandler Carruth <chandlerc@gmail.com>
Wed, 20 Oct 2010 08:44:27 +0000 (08:44 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Wed, 20 Oct 2010 08:44:27 +0000 (08:44 +0000)
use it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116920 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/Compiler.h

index 9ff78173c96b43868e2475caeca4206578431f0c..014e801282855329101647d233bca89c314cea8a 100644 (file)
 #define ATTRIBUTE_USED
 #endif
 
+// Some compilers warn about unused functions. When a function is sometimes
+// used or not depending on build settings (e.g. a function only called from
+// within "assert"), this attribute can be used to suppress such warnings.
+//
+// However, it shouldn't be used for unused *variables*, as those have a much
+// more portable solution:
+//   (void)unused_var_name;
+// Prefer cast-to-void wherever it is sufficient.
 #if (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
 #define ATTRIBUTE_UNUSED __attribute__((__unused__))
 #else