简体   繁体   English

从另一个Visual Studio项目调试Visual Studio C程序

[英]Debugging Visual Studio C program from another Visual Studio project

I have a Visual Studio 2012 solution containing several projects, some in C and some in Fortran (using Intel Composer XE 2013). 我有一个Visual Studio 2012解决方案,其中包含多个项目,一些项目使用C语言,有些项目使用Fortran(使用Intel Composer XE 2013)。 I frequently call from the Fortran code into the C code using the iso_c_binding utility, but I've noticed that I cannot debug the C code effectively. 我经常使用iso_c_binding实用程序从Fortran代码调用C代码,但是我注意到我无法有效地调试C代码。 While debugging the Fortran code, I can view the contents of variables just fine, but if I step into the C code, suddenly they lose their sanity. 在调试Fortran代码时,我可以很好地查看变量的内容,但是如果我进入C代码,则突然之间它们失去了理智。 Most variables just claim to be undefined; 大多数变量只是声称是未定义的。 anything passed to the function will contain incorrect values (but it still does differentiate between pointers and objects/POD). 传递给该函数的所有内容都将包含不正确的值(但仍会区分指针和对象/ POD)。

I can still step through the code; 我仍然可以单步执行代码; it seems to mostly follow the expected sequence of execution, but sometimes it does jump around a bit, which I'm familiar with from debugging compiler-optimized code on Linux with gdb. 它似乎大多遵循预期的执行顺序,但有时确实会跳一些,这是我在使用gdb在Linux上调试编译器优化的代码所熟悉的。

I have a separate solution that also has C and Fortran projects. 我有一个单独的解决方案,也有C和Fortran项目。 Both call into the same C project from the first solution, and in both cases, I can again debug successfully until I step into the C project from the first solution, at which point I have the same problems. 两者都从第一个解决方案调用同一个C项目,在两种情况下,我都可以再次成功调试,直到从第一个解决方案进入C项目为止,此时我遇到了相同的问题。

What am I doing wrong? 我究竟做错了什么?

This is the standard bat signal for debugging code that was optimized. 这是用于调试已优化代码的标准蝙蝠信号。 You'll need to rearrange you build settings so your Fortran code links to the non-optimized Debug build of the C code. 您需要重新排列构建设置,以便您的Fortran代码链接到C代码的未经优化的Debug构建。

There are no breadcrumbs in your question as to how that went wrong in the first place. 您的问题没有面包屑,一开始是怎么出问题的。 Start by checking which library is getting linked into your Fortran program and make sure that you can see distinct libraries generated for your C project in the Debug and Release builds. 首先检查哪个库已链接到您的Fortran程序中,并确保您可以在Debug and Release版本中看到为C项目生成的不同库。 You need to link the one created by the Debug build. 您需要链接由Debug构建创建的一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM