Repository: dtolnay/cxx (language: rust)

Issue:
Fails to cross-compile from linux to pc-windows-gnu
Official Windows documentation refers to it variously as **Basetsd.h** (https://docs.microsoft.com/en-us/windows/win32/winprog64/the-tools#include-files) and **BaseTsd.h** (https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types) but it appears the actual file they ship is **basetsd.h**. As reported by jebrosen in discord:

> the file is actually at `Program Files (x86)/Windows Kits/10/Include/10.0.18362.0/shared/basetsd.h` (lowercase) on my windows install. And of course windows being case-insensitive you probably wouldn't ever notice this except in cross-compilation

When cross compiling or compiling from a case sensitive filesystem, it fails to find out current import of BaseTsd.h added in #97.

```console
The following warnings were emitted during compilation:

warning: In file included from src/cxx.cc:1:
warning: src/../include/cxx.h:14:10: fatal error: 'BaseTsd.h' file not found
warning: #include <BaseTsd.h>
warning:          ^~~~~~~~~~~
warning: 1 error generated.

error: failed to run custom build command for `cxx v0.4.4 (/git/cxx)`

Caused by:
  process didn't exit successfully: `/git/cxx/target/debug/build/cxx-d96d8bbe071f88b7/build-script-build` (exit code: 1)
  --- stdout
  TARGET = Some("x86_64-pc-windows-gnu")
  OPT_LEVEL = Some("0")
  HOST = Some("x86_64-unknown-linux-gnu")
  CXX_x86_64-pc-windows-gnu = None
  CXX_x86_64_pc_windows_gnu = None
  TARGET_CXX = None
  CXX = Some("clang++")
  CXXFLAGS_x86_64-pc-windows-gnu = None
  CXXFLAGS_x86_64_pc_windows_gnu = None
  TARGET_CXXFLAGS = None
  CXXFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CXX_x86_64-pc-windows-gnu = None
  CXX_x86_64_pc_windows_gnu = None
  TARGET_CXX = None
  CXX = Some("clang++")
  CXXFLAGS_x86_64-pc-windows-gnu = None
  CXXFLAGS_x86_64_pc_windows_gnu = None
  TARGET_CXXFLAGS = None
  CXXFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  running: "clang++" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "--target=x86_64-pc-windows-gnu" "-Wall" "-Wextra" "-std=c++11" "-o" "/git/cxx/target/x86_64-pc-windows-gnu/debug/build/cxx-e9cfa76dc60ab8d1/out/src/cxx.o" "-c" "src/cxx.cc"
  cargo:warning=In file included from src/cxx.cc:1:
  cargo:warning=src/../include/cxx.h:14:10: fatal error: 'BaseTsd.h' file not found
  cargo:warning=#include <BaseTsd.h>
  cargo:warning=         ^~~~~~~~~~~
  cargo:warning=1 error generated.
  exit code: 1

  --- stderr


  error occurred: Command "clang++" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "--target=x86_64-pc-windows-gnu" "-Wall" "-Wextra" "-std=c++11" "-o" "/git/cxx/target/x86_64-pc-windows-gnu/debug/build/cxx-e9cfa76dc60ab8d1/out/src/cxx.o" "-c" "src/cxx.cc" with args "clang++" did not execute successfully (status code exit code: 1).
```


Discussion / hints:

Fix patch:
diff --git a/gen/src/include.rs b/gen/src/include.rs
index 54a359f98..1688a4e3d 100644
--- a/gen/src/include.rs
+++ b/gen/src/include.rs
@@ -61,7 +61,7 @@ pub struct Includes {
     pub type_traits: bool,
     pub utility: bool,
     pub vector: bool,
-    pub base_tsd: bool,
+    pub basetsd: bool,
 }
 
 impl Includes {
@@ -122,9 +122,9 @@ impl Display for Includes {
         if self.vector {
             writeln!(f, "#include <vector>")?;
         }
-        if self.base_tsd {
+        if self.basetsd {
             writeln!(f, "#if defined(_WIN32)")?;
-            writeln!(f, "#include <BaseTsd.h>")?;
+            writeln!(f, "#include <basetsd.h>")?;
             writeln!(f, "#endif")?;
         }
         Ok(())
diff --git a/gen/src/write.rs b/gen/src/write.rs
index a6f6c3ed7..862be814f 100644
--- a/gen/src/write.rs
+++ b/gen/src/write.rs
@@ -177,7 +177,7 @@ fn write_include_cxxbridge(out: &mut OutFile, apis: &[Api], types: &Types) {
                 needs_rust_slice = true;
             }
             ty if ty == Isize => {
-                out.include.base_tsd = true;
+                out.include.basetsd = true;
                 needs_rust_isize = true;
             }
             ty if ty == RustString => {
diff --git a/include/cxx.h b/include/cxx.h
index 3995924e5..b2e0eee56 100644
--- a/include/cxx.h
+++ b/include/cxx.h
@@ -11,7 +11,7 @@
 #include <utility>
 #include <vector>
 #if defined(_WIN32)
-#include <BaseTsd.h>
+#include <basetsd.h>
 #endif
 
 namespace rust {


Test patch: