Visual C ++ Build / Debugging Issue

I am having a strange problem with Visual Studio. Whenever I change my code and build, although I receive a notification that the built was successful (and if it is, it also shows errors in the code and does not build), the executable is actually the previous assembly. It becomes very annoying and frustrating.

If I put a breakpoint on new lines, the breakpoint is disabled and it says

At the moment, the breakpoint will not be deleted. There is no executable code. associated with this line. Possible reasons: preprocessor directive or compiler / linker optimization

If I put a breakpoint on the old lines of code, it stops processing, but shows me this message

The source is different from when the module was built. Would you like a debugger to use it anyway?

I have never had this problem before, and the source code is on my laptop hard drive. It saves immediately. The only way to get around this is to Clean entire solution manually each time, instead of basically pressing F5.

+4
source share
6 answers

Thanks to everyone for their suggestions. My mistake was that I defined the classes inside the .cpp files, this somehow forced the linker to do weird (maybe caching) things and bind old objects. I renamed the file to .h and everything works as expected.

+2
source

Perhaps your code is not built or built in a way that you do not expect.

You can verify by inserting the #error foobar preprocessor directive somewhere. If the creation does not display an error, you know that you have a problem!

But I never used Visual Studio (I use only Linux), so I can no longer help.

0
source

I think you are using source files from another project (for example: if you are using dll, say my.dll (which was created using some source files, say mycpp.cpp), in your current project). When you are debugging to a file (mycpp.cpp), you may have modified it.

Therefore, you need to rebuild the dll (my.dll) first in the project in which you created my.dll. Or Perhaps you opened an instance of mycpp.cpp in a window and debugged it in another window. you have to rebuild the dll.

If you are not using files from another project, I cannot guess the reason ... but I would recommend using rebuild rather than clean and build .

please clarify your question. @David is awaiting a response from you ...

0
source

You may have set up the main project for another project and created it. Make the project you want to work on as the "Main Project" using the main project, available on the menu bar.

0
source

I was looking for the answer to this question, since I also stuck to it. My colleague just gave me a solution that works. Yes, it seems really stupid, but it did the trick for me.

Our solution has many projects. He told me to select the project that I want to hack and install it as a startup project (right-click on the name of the project and select "Install as startup project"). I was desperate, so I tried. To my surprise, this works.

Since I opened this window, I thought I would share it if someone else gets stuck in this problem.

0
source

I ran into the same problem. But the mind was not like yours. Then I just restarted the visual studio and it worked as expected.

0
source

All Articles