Repository: pytorch
Issue: type conflict
Labels: module: cpp,triaged

### 🐛 Describe the bug

this is a c++ code.
when I compiler it, I got a compiler error.
this error occurs when I add `typedef struct data data` before `#include <torch/torch.h>`
The LibTorch I use is `libtorch-cxx11-abi-shared-with-deps-1.10.0+cu113.zip`, Ubuntu 22.04.
```
// main.cpp
typedef struct data data;
#include <torch/torch.h>
#include <iostream>
int main() {
  torch::Tensor tensor = torch::rand({2, 3});
  std::cout << tensor << std::endl;
}
```

compiler output
```
wsl@DESKTOP-ULB33J0:~/src/libtorch_test/build$ make
Consolidate compiler generated dependencies of target example-app
[ 50%] Building CXX object CMakeFiles/example-app.dir/example-app.cpp.o
In file included from /home/wsl/libtorch/include/torch/csrc/api/include/torch/enum.h:7,
                 from /home/wsl/libtorch/include/torch/csrc/api/include/torch/all.h:9,
                 from /home/wsl/libtorch/include/torch/csrc/api/include/torch/torch.h:3,
                 from /home/wsl/src/libtorch_test/example-app.cpp:2:
/home/wsl/libtorch/include/c10/util/variant.h: In instantiation of ‘static constexpr auto&& c10::detail_::access::base::get_alt(V&&) [with long unsigned int I = 0; V = const c10::detail_::base<c10::detail_::Trait::TriviallyAvailable, torch::ExpandingArray<1, long int>, torch::enumtype::kValid, torch::enumtype::kSame>&]’:
/home/wsl/libtorch/include/c10/util/variant.h:1205:31:   required from ‘static constexpr decltype(auto) c10::detail_::visitation::alt::visit_alt(Visitor&&, Vs&& ...) [with Visitor = c10::detail_::visitation::variant::value_visitor<torch::nn::functional::detail::conv1d(const at::Tensor&, const at::Tensor&, const at::Tensor&, torch::ExpandingArray<1>, const padding_t&, torch::ExpandingArray<1>, int64_t)::<lambda(const auto:14&)> >; Vs = {const c10::detail_::impl<torch::ExpandingArray<1, long int>, torch::enumtype::kValid, torch::enumtype::kSame>&}]’
/home/wsl/libtorch/include/c10/util/variant.h:1721:13:   required from ‘static constexpr decltype(auto) c10::detail_::visitation::variant::visit_alt(Visitor&&, Vs&& ...) [with Visitor = c10::detail_::visitation::variant::value_visitor<torch::nn::functional::detail::conv1d(const at::Tensor&, const at::Tensor&, const at::Tensor&, torch::ExpandingArray<1>, const padding_t&, torch::ExpandingArray<1>, int64_t)::<lambda(const auto:14&)> >; Vs = {const c10::variant<torch::ExpandingArray<1, long int>, torch::enumtype::kValid, torch::enumtype::kSame>&}]’
/home/wsl/libtorch/include/c10/util/variant.h:1736:13:   required from ‘static constexpr decltype(auto) c10::detail_::visitation::variant::visit_value(Visitor&&, Vs&& ...) [with Visitor = torch::nn::functional::detail::conv1d(const at::Tensor&, const at::Tensor&, const at::Tensor&, torch::ExpandingArray<1>, const padding_t&, torch::ExpandingArray<1>, int64_t)::<lambda(const auto:14&)>; Vs = {const c10::variant<torch::ExpandingArray<1, long int>, torch::enumtype::kValid, torch::enumtype::kSame>&}]’
/home/wsl/libtorch/include/c10/util/variant.h:2866:51:   required from ‘constexpr decltype(auto) c10::visit(Visitor&&, Vs&& ...) [with Visitor = torch::nn::functional::detail::conv1d(const at::Tensor&, const at::Tensor&, const at::Tensor&, torch::ExpandingArray<1>, const padding_t&, torch::ExpandingArray<1>, int64_t)::<lambda(const auto:14&)>; Vs = {const c10::variant<torch::ExpandingArray<1, long int>, torch::enumtype::kValid, torch::enumtype::kSame>&}]’
/home/wsl/libtorch/include/torch/csrc/api/include/torch/nn/functional/conv.h:35:20:   required from here
/home/wsl/libtorch/include/c10/util/variant.h:1181:7: error: invalid use of incomplete type ‘data’ {aka ‘struct data’}
 1181 |       AUTO_REFREF_RETURN(recursive_union::get_alt(
      |       ^~~~~~~~~~~~~~~~~~
/home/wsl/src/libtorch_test/example-app.cpp:1:16: note: forward declaration of ‘data’ {aka ‘struct data’}
    1 | typedef struct data data;
      |                ^~~~
```

Is there has a way to avoid this bug? thank you!

### Versions

Collecting environment information...
PyTorch version: 1.13.0+cu117
Is debug build: False
CUDA used to build PyTorch: 11.7
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.1 LTS (x86_64)
GCC version: (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
Clang version: Could not collect
CMake version: version 3.22.1
Libc version: glibc-2.35

Python version: 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] (64-bit runtime)
Python platform: Linux-5.15.90.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 11.7.99
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3050 Laptop GPU
Nvidia driver version: 516.54
cuDNN version: Probably one of the following:
/usr/local/cuda-11.7/targets/x86_64-linux/lib/libcudnn.so.8.9.1
/usr/local/cuda-11.7/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.9.1
/usr/local/cuda-11.7/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.9.1
/usr/local/cuda-11.7/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.9.1
/usr/local/cuda-11.7/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.9.1
/usr/local/cuda-11.7/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.9.1
/usr/local/cuda-11.7/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.9.1
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Address sizes:                   48 bits physical, 48 bits virtual
Byte Order:                      Little Endian
CPU(s):                          16
On-line CPU(s) list:             0-15
Vendor ID:                       AuthenticAMD
Model name:                      AMD Ryzen 7 5800H with Radeon Graphics
CPU family:                      25
Model:                           80
Thread(s) per core:              2
Core(s) per socket:              8
Socket(s):                       1
Stepping:                        0
BogoMIPS:                        6387.82
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl tsc_reliable nonstop_tsc cpuid extd_apicid pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy svm cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw topoext perfctr_core ssbd ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves clzero xsaveerptr arat npt nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold v_vmsave_vmload umip vaes vpclmulqdq rdpid fsrm
Virtualization:                  AMD-V
Hypervisor vendor:               Microsoft
Virtualization type:             full
L1d cache:                       256 KiB (8 instances)
L1i cache:                       256 KiB (8 instances)
L2 cache:                        4 MiB (8 instances)
L3 cache:                        16 MiB (1 instance)
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Mmio stale data:   Not affected
Vulnerability Retbleed:          Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccompVulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; Retpolines, IBPB conditional, IBRS_FW, STIBP conditional, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected

Versions of relevant libraries:
[pip3] numpy==1.24.3
[pip3] torch==1.13.0+cu117
[pip3] torchaudio==0.13.0+cu117
[pip3] torchvision==0.14.0+cu117
[conda] Could not collect

cc @jbschlosser