Program input (cin or getline) is read in correct

2019-07-23 20:32发布

I'm having trouble trying to debug C++ with input from cin and/or getline. It works perfectly when I run instead of debug. I'm using Eclipse neon CDT in Windows 8.1 with MinGW compiler/debugger (64bit). Running a sample program to isolate the issue that uses getline for input and extracts the first character for comparison:

while (true) {
  cout << "Enter x to exit: ";
  getline(cin, input);
  myChar = input[0];
  if (myChar=='x') {
    break;
  }

  cout << "You entered: " <<myChar<<endl;
}
cout <<"Exiting..."<<endl;

When I run it - it works perfectly. However when I try to debug, it either a) doesn't wait for input and makes up it's own, or b) ignores my input and makes up it's own. I've seen both of these happen when experimenting in different projects.

I thought maybe I needed to make sure it was reading chars as UTF-8. But the settings I found seem to be for the text editor or text files (Window->Preferences->General->Workspace)...not the console.

I read that there are sometimes issues with console input and tried using native Windows console instead of the IDE integrated one as described here: http://nicolas.riousset.com/eclipse-how-to-debug-a-c-console-application-using-a-native-dos-console-instead-of-the-ide-integrated-one/

Unfortunately then I just get an error when trying to launch the debugger:

Error in final launch sequence Failed to execute MI command: record Error message from debugger back end: Process record: the current architecture doesn't support record function. Process record: the current architecture doesn't support record function.

1条回答
Summer. ? 凉城
2楼-- · 2019-07-23 20:44

Unfortunately then I just get an error when trying to launch the debugger:

Error in final launch sequence Failed to execute MI command: record Error message from debugger back end: Process record: the current architecture doesn't support record function. Process record: the current architecture doesn't support record function.

It sounds like you're running into a bug in Eclipse Neon.

The bug was fixed in the Neon.1 update. If you download the latest version of Eclipse (Neon.3 at the time of writing this) it will include the fix.

查看更多
登录 后发表回答