托管 C++ - 忽略头文件
所以我在托管 C++ VS2010 解决方案中有一个 HEADER(.h) 和一个 SOURCE(.cpp) 文件。
即使我向标头添加了垃圾,我的解决方案也能成功构建。
public:
someConstructor(); // assume the syntax is good here
asdf // garbage
为什么这样做
我最初的问题是我无法更新我的 CPP 文件来添加新的构造函数。当我向 CPP 文件添加新的构造函数时,由于不存在的重写成员函数(即我的新构造函数),我的解决方案无法构建。我向 HEADER 文件添加了垃圾,以确保 VS2010 实际上正在读取我的 HEADER 文件。显然事实并非如此。
我如何确保 VS2010 会查看我的 HEADER 文件?它似乎正在查看另一个标头文件...
谢谢
So I’ve got a HEADER(.h) and a SOURCE(.cpp) file in a Managed C++ VS2010 solution.
My solution builds successfully even though I added garbage to the header.
public:
someConstructor(); // assume the syntax is good here
asdf // garbage
Why I did this
My original problem was that I couldn't update my CPP file to add a new constructor. When I added a new constructor to my CPP file, my solution failed to build due to a non-existent overridden member function, i.e. my new constructor. I added garbage to the HEADER file to make sure that VS2010 was actually reading my HEADER file. Obviously it was not.
How can I make sure that VS2010 looks at my HEADER file? It seems to be looking at another HEADER file...
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您选择有问题的文件并打开属性窗口(
View->Properties Window
),您可以查看您的项目是否正在查看正确的文件。此外,如果该文件未包含在构建中(即使它包含在解决方案中),则可以将Include in Project
设置为 true。请注意,我假设您正在使用 MSBuild。如果您使用其他构建系统,则可能有不同的过程来确保构建使用正确的头文件。
If you select the file(s) in question and open up the properties window (
View->Properties Window
) you can see if your project is looking at the correct file or not. Additionally, if the file is not being included in the build (even though it's in the solution), you can setInclude in Project
to true.Note that I'm assuming you're using MSBuild. If you're using some other build system, there may be a different procedure for ensuring the build is using the correct header file.