C++断点将被忽略/错过

C++ breakpoints are ignored / missed

本文关键字:错过 断点 C++      更新时间:2023-10-16

我正在尝试运行某人给我的一些C++代码。起初有一个指向istream文件的链接断开,我通过添加包含路径来修复它:

C:Program Files (x86)EmbarcaderoRAD Studio7.0includedinkumware

代码现在可以编译,但它不会在任何断点处停止,例如formcreate中的断点:

// Initialise the form and read in the module and inverter names.
void __fastcall TMain::FormCreate(TObject *Sender)
{
    ifstream inits;
    ifstream inverters;
    ifstream modules;
    char line[1000];
    AnsiString FTO;
    inits.open("PVSM.ini", ios::in);
    if (inits.is_open())
    {
            inits.getline(line,1000);
            AnsiString parmm(line);
            ModDir = parmm.SubString(1,parmm.Pos(" ")-1);
            inits.getline(line,1000);
            AnsiString parmi(line);
            InvDir = parmi.SubString(1,parmi.Pos(" ")-1);
            inits.getline(line,1000);
            AnsiString parmt(line);
            MetDir = parmt.SubString(1,parmt.Pos(" ")-1);
            inits.getline(line,1000);
            AnsiString parms(line);
            ShdDir = parms.SubString(1,parms.Pos(" ")-1);
            inits.getline(line,1000);
            AnsiString parmx(line);
            ExpDir = parmx.SubString(1,parmx.Pos(" ")-1);
    }
    else    // Should never get here, but if ini file missing use defaults
    {
        ModDir = "C://";
        InvDir = "C://";
        MetDir = "C://";
        ShdDir = "C://";
    }
    inits.close();
    FTO = InvDir + "inverters.data";
    inverters.open(FTO.c_str(), ios::in);
    if (inverters.is_open())
    {
            while ( inverters.getline(line,1000) )
            {
               AnsiString inverter(line);
               IVBox->Items->Add(inverter);
            }
    }
    inverters.close();
    FTO = ModDir + "modules.data";
    modules.open(FTO.c_str(), ios::in);
    if (modules.is_open())
    {
            while ( modules.getline(line,1000) )
            {
               AnsiString module(line);
               ModBox->Items->Add(module);
            }
    }
    modules.close();
    CMod = 1;
    CStr = 1;
    CCell = 1;
    nStore = 0;
    grid = true;
    pasan = false;
    debug = false;
    calc = false;
    cell = false;
    module = false;
    array1 = false;
    inv = false;
    PV = true;
    Parray = false;
    Pcurve = false;
    LastType = 'X';
    CurrTp = -1;  //* Not currently set
    AllSame = true;
    LdMeteo = false;
    mpp = true;
}

它只是打开表单,就好像它是从.exe文件中运行的一样,除了它显示

编译 MyProject.cbproj (Release configuration)....成功

在消息栏中

我尝试从发布模式切换到调试模式,尝试更改输出目录,以便它编译新的.obj文件。没有成功。

我正在运行Rad studio 2010,它最初是用XE5写的,但我认为这是文件夹结构而不是IDE版本的问题?

有什么建议吗?

一些可能对您有用也可能没有用的想法(来自各种来源):

  • 确保使用的是调试配置并执行项目的生成,而不仅仅是编译:切换回调试配置并在发布生成后进行编译是不够的
  • 在 Win32(调试)的项目选项中,请确保将以下选项设置为正确的值

    • [C++编译器] → [调试] → [调试信息] = True ;
    • [C++编译器] → [调试]
    • → [调试行号信息] = True ;
    • [C++编译器] → [优化]
    • → [禁用所有优化] = True ;
    • [C++编译器] → [
    • 优化] → [生成尽可能快的代码] = False ;
    • [C++链接器] → [完整调试信息] = True ;
    • [德尔福编译器] → [优化] = False ;
    • [德尔福编译器] → [使用调试.dcus] = True ;

    (例如,MDI 应用程序的默认配置模板错误)

  • 删除所有.pch.#.tds文件,让编译器重新创建
  • 如果您在 VirtualBox 下运行 IDE,请考虑某些版本存在断点问题 (v4.3.x)

作为最后的手段,您可以尝试{ _asm { int 3 } }模拟断点。

另请查看:

  • 质量中心
  • Delphi:为什么不时断点不可用(IDE上的绿色突出显示线)?