Flags to build cpp extension on Windows

username: Victory
cooked: <p>While trying to build a Facebook provided PyTorch extension on Windows, I see syntax errors related to PyTorch header code such as the following. Are there some standard set of flags that need to be passed to the “cl” compiler on Windows to not get these errors? Otherwise, I wonder how any PyTorch extension would build on Windows since these are common headers.<br>
Thanks!</p>
<pre><code class="lang-auto">pathToCondaEnv\lib\site-packages\torch\include\ATen/core/Dict.h(98): error C2990: 'c10::Dict': non-class template has already been declared as a class template
pathToCondaEnv\lib\site-packages\torch\include\ATen/core/Dict.h(13): note: see declaration of 'c10::Dict'
pathToCondaEnv\lib\site-packages\torch\include\ATen/core/Dict.h(99): note: see reference to class template instantiation 'c10::impl::DictEntryRef&lt;Key,Value,Iterator&gt;' being compiled
pathToCondaEnv\lib\site-packages\torch\include\ATen/core/Dict.h(98): error C2059: syntax error: '&lt;'
pathToCondaEnv\lib\site-packages\torch\include\ATen/core/Dict.h(98): error C2238: unexpected token(s) preceding ';'
pathToCondaEnv\lib\site-packages\torch\include\ATen/core/Dict.h(177): error C2990: 'c10::Dict': non-class template has already been declared as a class template
pathToCondaEnv\lib\site-packages\torch\include\ATen/core/Dict.h(13): note: see declaration of 'c10::Dict'
pathToCondaEnv\lib\site-packages\torch\include\ATen/core/Dict.h(178): note: see reference to class template instantiation 'c10::impl::DictIterator&lt;Key,Value,Iterator&gt;' being compiled
pathToCondaEnv\lib\site-packages\torch\include\ATen/core/Dict.h(177): error C2059: syntax error: '&lt;'
...
pathToCondaEnv\lib\site-packages\torch\include\ATen/core/List.h(76): error C2990: 'c10::List': non-class template has already been declared as a class template
pathToCondaEnv\lib\site-packages\torch\include\ATen/core/List.h(16): note: see declaration of 'c10::List'
pathToCondaEnv\lib\site-packages\torch\include\ATen/core/List.h(80): note: see reference to class template instantiation 'c10::impl::ListElementReference&lt;T,Iterator&gt;' being compiled
pathToCondaEnv\lib\site-packages\torch\include\ATen/core/List.h(76): error C2059: syntax error: '&lt;'
pathToCondaEnv\lib\site-packages\torch\include\ATen/core/List.h(76): error C2238: unexpected token(s) preceding ';'
pathToCondaEnv\lib\site-packages\torch\include\ATen/core/List.h(177): error C2990: 'c10::List': non-class template has already been declared as a class template
pathToCondaEnv\lib\site-packages\torch\include\ATen/core/List.h(16): note: see declaration of 'c10::List'
pathToCondaEnv\lib\site-packages\torch\include\ATen/core/List.h(178): note: see reference to class template instantiation 'c10::impl::ListIterator&lt;T,Iterator&gt;' being compiled
pathToCondaEnv\lib\site-packages\torch\include\ATen/core/List.h(177): error C2059: syntax error: '&lt;'
</code></pre>

username: tom
cooked: <p>The thing I always look to is arguably the most popular PyTorch extension - <a href="https://github.com/pytorch/vision/blob/master/setup.py#L284" rel="nofollow noopener">torchvision</a>. Building it is much easier than building PyTorch and you’ll be able to observe what it is doing.<br>
In fact, I would recommend to imitate TorchVision’s method of building the extension.</p>
<p>Best regards</p>
<p>Thomas</p>