Platform header test

Are there any plans for testing compilations of the headers on the various platforms?

I would like to look into getting Visual Studio and Windows headers to compile, and the first step would be to see where we are.

I’m thinking that if we had some tests that just include individual headers and just syntax check them, that would both give us this information, as well as become a regression test.

What I’ve done locally is to create an “Includes” directory under “test”, and put in simple tests of the form:

// RUN: clang -fsyntax-only %s
#include <stdio.h>

I’m using the clang driver because of the -fms-extension issue.

Since headers might act differently between C and C++, perhaps each test should have two compile commands, one for C and one for C++. (I haven’t figured out the right options to do that yet with the clang driver.)

Since stdio.h might include other files, I test those separately. Since these might be platform-specific, I’d use conditionals:

// This test is for Windows only.
// RUN: clang -fsyntax-only %s
#if defined(WIN32) || defined(WIN64)
#include <crtdefs.h>

Platform and complier-specific files probably should be in separate directories, perhaps under Includes, i.e.:


I separated VisualStudio and Windows with respect to the files under Visual Studio and those under the Platform SDK also being separated, but they could be combined.

Anyway, let me know what you think.

We definitely want to do this kind of testing. lit actually has some support already for "try to syntax-check all of the headers in a given directory". Check out, for example, clang/utils/C++Tests/stdc++-Syntax, which checks the GCC 4.2.1 C++ headers. Run it from the clang source directory with, e.g.,

  lit -sv utils/C++Tests/stdc++-Syntax

  - Doug

Oh, and of course... I think it would be great to have utils/WindowsSDK and such. We don't automatically run all of the tests in utils, so it's okay to have platform-specific stuff in there.

  - Doug

Right, to continue on with that thought, my plan (not yet implemented) is to add
as a dumping ground for all the extra tests which we know how to
write, but don't feel like putting in the regular test suite
(non-portable, system dependencies, slow, whatever). I'll probably
move the existing C++Tests directory there once I get around to it.

- Daniel