Build problems when using TensorFlow Lite from another project in Windows
Hi @martaiborra, this seems like a MVC++ compiler issue, it doesn't like the implicit cast from bool to const std::atomic_flag.  Is there a way you can switch to clang? That will be better supported now and in the future. I was able to run your scripts successfully on a Linux (Debian) distribution with clang. (Unless your scripts somehow manually changed compilers)

```sh
git clone https://github.com/Blosc/blosc2_btune.git
cd blosc2_btune
python -m pip install -r requirements-build.txt
chmod 755 prebuild.sh
./prebuild.sh
python setup.py bdist_wheel
```

Alternatively you can try with WSL as well. Hi, thank you for your answer.
One reason because we wanted to use MSVC it's because the project is a python extension and the usually used compiler for that is MSVC but  I will try to use clang and see.

Also, it is really interesting because if I try to compile TensorFlow Lite alone with MSVC, it works totally fine:
```
mkdir tflite_build
cd tflite_build
cmake ../tensorflow/lite
cmake --build . -j
```

 Tried using Clang from the Visual Studio Build tools. I got an error when building TensorFlow Lite alone (not inside the blosc2_btune project).

```
cmake ..\tensorflow\lite -G "Visual Studio 17 2022" -T ClangCL -A x64
cmake --build . -j
```

The following error occurs:

```
Building Custom Rule C:/Users/marta/blosc2_btune/tensorflow_src/tflite_build/xnnpack/CMakeLists.txt
  operator-utils.vcxproj -> C:\Users\marta\blosc2_btune\tensorflow_src\tflite_build\_deps\xnnpack-build\operator-utils.
  dir\Debug\operator-utils.lib
  indirection.vcxproj -> C:\Users\marta\blosc2_btune\tensorflow_src\tflite_build\_deps\xnnpack-build\indirection.dir\De
  bug\indirection.lib
  In file included from C:\Users\marta\blosc2_btune\tensorflow_src\tflite_build\cpuinfo\src\x86\topology.c:5:
C:\Users\marta\blosc2_btune\tensorflow_src\tflite_build\cpuinfo\src\cpuinfo/utils.h(13,4): error : call to undeclared l
ibrary function '_BitScanReverse' with type 'unsigned char (unsigned long *, unsigned long)'; ISO C99 and later do not
support implicit function declarations [-Wimplicit-function-declaration] [C:\Users\marta\blosc2_btune\tensorflow_src\tf
lite_build\_deps\cpuinfo-build\cpuinfo.vcxproj]
C:\Users\marta\blosc2_btune\tensorflow_src\tflite_build\cpuinfo\src\cpuinfo/utils.h(13,4): message : include the header
 <intrin.h> or explicitly provide a declaration for '_BitScanReverse' [C:\Users\marta\blosc2_btune\tensorflow_src\tflit
e_build\_deps\cpuinfo-build\cpuinfo.vcxproj]
  operator-run.vcxproj -> C:\Users\marta\blosc2_btune\tensorflow_src\tflite_build\_deps\xnnpack-build\operator-run.dir\
  Debug\operator-run.lib
  memory.vcxproj -> C:\Users\marta\blosc2_btune\tensorflow_src\tflite_build\_deps\xnnpack-build\memory.dir\Debug\memory
  .lib
``` Hi @martaiborra, Have you ensured you followed these instructions? https://clang.llvm.org/get_started.html specifically the "Using Visual Studio" section? Alternatively, can you use WSL to continue/compile your project? Hi, I'll check that. With WSL works perfectly fine, but we wanted to be able to use it without the need of WSL. This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. Tried using Clang following the instructions and it works for tensorflow alone. I'm still trying to figure out how to use clang when creating the wheels.  Tried using clang and it shows the same error. Instead of creating the wheel, I tried to only use cmake with:

```
cd blosc2_btune
mkdir build
cd build
cmake -DLLVM_ENABLE_PROJECTS=clang -G "Visual Studio 17 2022" -A x64 -Thost=x64 ..
cmake --build . -j
```

But it stills shows the same error.
```
  btune_model.cpp
C:\Users\marta\blosc2_btune\tensorflow_src\tensorflow/lite/core/interpreter.h(1002,40): error C2665: 'std::atomic_flag::atomic_fl
ag': no overloaded function could convert all the argument types [C:\Users\marta\blosc2_btune\build\src\blosc2_btune.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.37.32822\include\atomic(2886,1): message : could
be 'std::atomic_flag::atomic_flag(const std::atomic_flag &)' [C:\Users\marta\blosc2_btune\build\src\blosc2_btune.vcxproj]
C:\Users\marta\blosc2_btune\tensorflow_src\tensorflow/lite/core/interpreter.h(1002,40): message : 'std::atomic_flag::atomic_flag(
const std::atomic_flag &)': cannot convert argument 1 from 'bool' to 'const std::atomic_flag &' [C:\Users\marta\blosc2_btune\buil
d\src\blosc2_btune.vcxproj]
C:\Users\marta\blosc2_btune\tensorflow_src\tensorflow/lite/core/interpreter.h(1002,41): message : Reason: cannot convert from 'bo
ol' to 'const std::atomic_flag' [C:\Users\marta\blosc2_btune\build\src\blosc2_btune.vcxproj]
C:\Users\marta\blosc2_btune\tensorflow_src\tensorflow/lite/core/interpreter.h(1002,40): message : while trying to match the argum
ent list '(bool)' [C:\Users\marta\blosc2_btune\build\src\blosc2_btune.vcxproj]
```
 Hi @martaiborra, I think your root issue might have to do with the MVC++ compiler, I am unsure if not being able to do that cast is uncompliant w/ the C++ standard or not, so you might want to check with the MVC++ team to see if this is their root issue. It seems you are able to continue with WSL so I recommend you continue working with that stack until this issue is resolved.

Hi @terryheo, can you please take a look at this issue? Thanks. Hi, we found out the problem. In our CMakeLists.txt we had:
`set (CMAKE_CXX_STANDARD 20)`

By downgrading it to:
`set (CMAKE_CXX_STANDARD 17)`
it does not complain anymore.

Thank you very much for your help! Hi @martaiborra, thank you for the update, please feel free to close the issue as completed if you have no more open issues. Thanks. Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/61890">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/61890">No</a>
 The documentation at
https://en.cppreference.com/w/cpp/atomic/atomic_flag/atomic_flag
makes it pretty clear that this is not standard-conforming code,
for all versions of the C++ standard.

I have made a patch to use ATOMIC_FLAG_INIT instead
<https://en.cppreference.com/w/cpp/atomic/ATOMIC_FLAG_INIT>
and have sent that for review.

### Issue type

Build/Install

### Have you reproduced the bug with TensorFlow Nightly?

No

### Source

source

### TensorFlow version

2.13

### Custom code

Yes

### OS platform and distribution

Windows 10

### Mobile device

_No response_

### Python version

3.11

### Bazel version

compiled using CMake

### GCC/compiler version

MSVC 17 2022

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

When trying to create a project wheel which uses TensorFlow Lite, it is expected to work fine with:
`python setup.py bdist_wheel`

This command works fine for MacOS and Linux but does not work for Windows raising an error from the `tensorflow_src\tensorflow/lite/core/interpreter.h` file (you can see the error in the Relevant log output section).

For using TensorFlow Lite from the project, we followed the instructions in https://www.tensorflow.org/lite/guide/build_cmake#create_a_cmake_project_which_uses_tensorflow_lite as can be seen in its CMake files (https://github.com/Blosc/blosc2_btune/blob/main/src/CMakeLists.txt).

Also, there is no issue even on Windows for building TensorFlow Lite alone with 
```
cmake ../tensorflow_src/tensorflow/lite
cmake --build . -j
```

### Standalone code to reproduce the issue

```shell
The issue project is blosc2_btune (https://github.com/Blosc/blosc2_btune). You can clone it

`git clone https://github.com/Blosc/blosc2_btune.git`

install the requirements

`python -m pip install -r requirements-build.txt`

and reproduce the error with


prebuild.sh
python setup.py bdist_wheel
```
```


### Relevant log output

```shell
Generating Code...
  btune_model.cpp
C:\Users\marta\blosc2_btune\tensorflow_src\tensorflow/lite/core/interpreter.h(1000,40): error C2665: 'std::atomic_flag:
:atomic_flag': no overloaded function could convert all the argument types [C:\Users\marta\blosc2_btune\_skbuild\win-am
d64-3.11\cmake-build\src\blosc2_btune.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.37.32822\include\atomic(2886,1): messag
e : could be 'std::atomic_flag::atomic_flag(const std::atomic_flag &)' [C:\Users\marta\blosc2_btune\_skbuild\win-amd64-
3.11\cmake-build\src\blosc2_btune.vcxproj]
C:\Users\marta\blosc2_btune\tensorflow_src\tensorflow/lite/core/interpreter.h(1000,40): message : 'std::atomic_flag::at
omic_flag(const std::atomic_flag &)': cannot convert argument 1 from 'bool' to 'const std::atomic_flag &' [C:\Users\mar
ta\blosc2_btune\_skbuild\win-amd64-3.11\cmake-build\src\blosc2_btune.vcxproj]
C:\Users\marta\blosc2_btune\tensorflow_src\tensorflow/lite/core/interpreter.h(1000,41): message : Reason: cannot conver
t from 'bool' to 'const std::atomic_flag' [C:\Users\marta\blosc2_btune\_skbuild\win-amd64-3.11\cmake-build\src\blosc2_b
tune.vcxproj]
C:\Users\marta\blosc2_btune\tensorflow_src\tensorflow/lite/core/interpreter.h(1000,40): message : while trying to match
 the argument list '(bool)' [C:\Users\marta\blosc2_btune\_skbuild\win-amd64-3.11\cmake-build\src\blosc2_btune.vcxproj]
Traceback (most recent call last):
  File "C:\Users\marta\miniconda3\envs\blosc2_btune2\Lib\site-packages\skbuild\setuptools_wrap.py", line 674, in setup
    cmkr.make(make_args, install_target=cmake_install_target, env=env)
  File "C:\Users\marta\miniconda3\envs\blosc2_btune2\Lib\site-packages\skbuild\cmaker.py", line 697, in make
    self.make_impl(clargs=clargs, config=config, source_dir=source_dir, install_target=install_target, env=env)
  File "C:\Users\marta\miniconda3\envs\blosc2_btune2\Lib\site-packages\skbuild\cmaker.py", line 742, in make_impl
    raise SKBuildError(msg)

An error occurred while building with CMake.
  Command:
    'C:\Users\marta\miniconda3\envs\blosc2_btune2\Lib\site-packages\cmake\data\bin/cmake.exe' --build . --target install --config Release --
  Install target:
    install
  Source directory:
    C:\Users\marta\blosc2_btune
  Working directory:
    C:\Users\marta\blosc2_btune\_skbuild\win-amd64-3.11\cmake-build
Please check the install target is valid and see CMake's output for more information.
```
