c++ - Visual Studio 需要为每次更改重建解决方案

标签 c++ visual-studio opengl visual-studio-2017 glfw

我目前正在使用 C++ 开发游戏引擎。随着项目的进一步推进,我注意到生成的可执行文件通常不会反射(reflect)最新的代码更改。但是完全清理解决方案并重建它可以解决问题。不幸的是,对于更大的代码库,完全重建不再是可行的选择。

我已经在 stackoverflow 上检查了不同的解决方案:

  • 我检查过我的“Build and Run”设置是否设置为“Always build ”
  • Configuration Manager 也设置为“Build”

附加信息:

  • 这是一个 OpenGL 项目,带有 GLFWglad 在 c++ 中
  • 我使用 Visual Studio Community 2017 版本 15.2

这是一个非常烦人的问题,会导致大量生产力损失,因为每次我想看到更改时,我都必须完全重建整个解决方案。如果有任何意见,我将不胜感激。请询问是否需要更多信息。

我不知道这是否有任何相关性,但这是我对 TestScene.cpp 进行小改动并重新运行代码时得到的结果: enter image description here


更新

下面是对这个问题的深入解释:

  1. 我有一个允许旋转对象的类 TransformerScript.cpp
  2. 我已将旋转速度设置为 1。
  3. 对象按预期旋转。

enter image description here

  1. 现在我将速度浮点值从 1 更改为 0。
  2. 我按下运行(本地 Windows 调试器)
  3. 这是输出日志:

1>------ Build started: Project: Star-Engine, Configuration: Debug x64 ------

1>TransformerScript.cpp

1>c:\users\haeri\documents\github\space-engine\star-engine\src\header\matrix4f.h(44): warning C4267: 'argument': conversion from 'size_t' to 'unsigned int', possible loss of data

1>c:\users\haeri\documents\github\space-engine\star-engine\src\header\matrix4f.h(44): warning C4244: 'initializing': conversion from 'float' to 'int', possible loss of data

1>c:\users\haeri\documents\github\space-engine\star-engine\src\header\matrix4f.h(45): warning C4267: 'argument': conversion from 'size_t' to 'unsigned int', possible loss of data

1>c:\users\haeri\documents\github\space-engine\star-engine\src\source\transformerscript.cpp(13): warning C4244: 'argument': conversion from 'double' to 'float', possible loss of data

1>Compiling...

1>Generating Code...

1>Skipping... (no relevant changes detected)

1>TestScene.cpp

1>Star-Engine.vcxproj -> C:\Users\haeri\Documents\github\Space-Engine\x64\Debug\Star-Engine.exe

c:\users\haeri\documents\github\space-engine\star-engine\src\source\glad.c(51): warning C6308: 'realloc' might return null pointer: assigning null pointer to 'exts_i', which is passed as an argument to 'realloc', will cause the original memory block to be leaked.

c:\users\haeri\documents\github\space-engine\star-engine\include\stb\stb_image.h(3667): warning C6001: Using uninitialized memory 'coutput'.

1>Star-Engine.vcxproj -> C:\Users\haeri\Documents\github\Space-Engine\x64\Debug\Star-Engine.pdb (Partial PDB)

1>Done building project "Star-Engine.vcxproj".

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

  1. 编译后的可执行文件开始
  2. 结果是同一个图形以相同的速度旋转。
  3. 预期行为:没有旋转,因为 float 设置为 0。
  4. 我被迫“清理解决方案”和“重建解决方案”
  5. 这在我的笔记本电脑上大约需要 1 到 2 分钟
  6. VS 完成重建新解决方案
  7. 我按下运行(本地 Windows 调试器)
  8. 物体没有移动。 (这是预期的)

替代方法

  1. 在速度浮点值的位置设置断点
  2. 我按下运行(本地 Windows 调试器)
  3. 有时(90% 的情况)会弹出错误提示。其他时候(10% 的情况)一切都按预期进行

enter image description here

  1. 我按确定
  2. 编译后的可执行文件开始
  3. 结果是同一个图形以相同的速度旋转。
  4. 预期行为:没有旋转,因为 float 设置为 0。
  5. 断点触发!

最佳答案

我的一个 C# 项目遇到了同样的问题,并且这样解决了:

  1. 转到解决方案 > 属性
  2. 检查配置属性 > 配置
  3. 在我的例子中,没有为解决方案中的一个项目检查构建标志

关于c++ - Visual Studio 需要为每次更改重建解决方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45688562/

相关文章:

c++ - STL 容器有单元测试吗?

c++ - 将 '_' 更改为 ' ' 根本不起作用

c++ - 如何访问 3 维矩阵元素?

c# - 如何在 TFS 工作项中添加包含计算字段的选项卡

c++ - 单个继承的派生类的大小

c++ - 类型安全的可变参数函数

.net - 将.NET 4.0 dll安装到GAC

opengl - glFrustum 函数有什么作用?

c++ - GL 或 GLUT 有问题

c++ - OpenGL 中的像素操作