Visual Studio 2015 Update 1, clang error

后端 未结 2 1106
半阙折子戏
半阙折子戏 2021-01-13 05:35

when trying to use new clang with Visual Codegen in my project (Visual Studio 2015 Update 1), I\'m getting following error:

clang.exe : error : cannot specif         


        
相关标签:
2条回答
  • 2021-01-13 06:03

    It is not very clear what you are doing but it seems obvious that you are not using one of the Clang project templates in the Cross Platform node. I can repro your problem by using the Win32 > Win32 Project template and changing the project's Platform Toolset selection to "Clang 3.7".

    That doesn't work, it completely flubs the precompiled header feature. It is somehow convinced that it needs to compile stdafx.h. Not just once, it passes it the compiler twice. Which makes Clang barf with this error message, it will only accept one file at a time. It also doesn't know how to take advantage of Clang's PCH support, no sign of the required -emit-pch option.

    You'll need to get ahead by turning the feature off. Project > Properties > C/C++ > Precompiled Headers > Precompiled Header = "Not using...". Select stdafx.cpp and repeat.

    That solves the build problem, the final executable somewhat surprising runs without issue. It should be somewhat clear that you are using Clang in a scenario that was never tested by Microsoft. Looks like the IntelliSense parser is going to need a lot more work as well. Afaik Clang support was intended to target Android and iOS, current version is alpha quality.

    0 讨论(0)
  • 2021-01-13 06:19

    Just as an addition to the accepted answer, if you are still experiencing this issue even after setting Precompiled Header = "Not using...". The other issue might be an incorrect value in the Object File Name field.

    That field can be found under: Project > Properties > C/C++ > General > Object File Name = $(IntDir)%(filename).obj

    Note: originally discover this solution here: http://www.progtown.com/topic2009949-clang

    0 讨论(0)
提交回复
热议问题