<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - -Wheader-guard fires for non-header files"
   href="http://llvm.org/bugs/show_bug.cgi?id=17053">17053</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>-Wheader-guard fires for non-header files
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>nicolasweber@gmx.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider this code:

$ cat test.h
#ifndef TEST_H_
#define TEST_H_

#ifdef CONFIGURE_TEST_INCLUDE
typedef int MyInt;
#endif  // CONFIGURE_TEST_INCLUDE

#endif  // TEST_H_

$ cat test.c
#ifndef EXCLUDE_C_FILES

#define CONFIGURE_TEST_INCLUDE
#include "test.h"

int main(){}

#endif  // EXCLUDE_C_FILES



Here, the .h file has a correct header guard and does some stuff optionally
based on a define. The .c file is guarded by some preprocessor macro, so that
the file can be disabled at build time.

-Wheader-guard complains about the .c file:

$ ~/src/chrome-git/src/third_party/llvm-build/Release+Asserts/bin/clang -c
test.c
test.c:1:9: warning: 'EXCLUDE_C_FILES' is used as a header guard here, followed
by #define of a different macro [-Wheader-guard]
#ifndef EXCLUDE_C_FILES
        ^~~~~~~~~~~~~~~
test.c:3:9: note: 'CONFIGURE_TEST_INCLUDE' is defined here; did you mean
'EXCLUDE_C_FILES'?
#define CONFIGURE_TEST_INCLUDE
        ^~~~~~~~~~~~~~~~~~~~~~
        EXCLUDE_C_FILES
1 warning generated.


...but the .c file is fine as is. -Wheader-guard shouldn't warn about wrong
header guards in the main translation unit.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>