c - Eclipse 中的 GDB 调试器找不到 FILE

标签 c gdb eclipse-cdt

我正在调试这段代码:

int main(int argc, char* argv[]) {
    if (argc != 2) {
        fprintf(stderr, "Error: Add filepath to a chessposition");
        return EXIT_FAILURE;
    }
    FILE* pchess_file = fopen(argv[1], "r");
    if(!pchess_file){
        perror("Error: File not found");
        return EXIT_FAILURE;
    }
    CHESS_STATE chess_state;

    loadBoard(&chess_state.board_state, pchess_file);
    printBoard(&chess_state.board_state);
    //valdiate board

}

我指定了参数“board.chess”,并且表示的文件被放置在调试文件夹中。然而,Eclipse似乎改变了目录。当照常执行时,代码可以工作。

Structure of the Project

最佳答案

解决方案是调试时Eclipse运行在“Project”目录中,而不是“Project/Debug”目录中。

将所有文件移至“Odin”文件夹中。

关于c - Eclipse 中的 GDB 调试器找不到 FILE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57240342/

相关文章:

将 char 数组转换为 atoi 失败

c - gdb 目标远程 :1234 connection timeout linux

python - Linux 上 Python 中的环境变量

debugging - 无法在 gdb 中禁用分页

c++ - 使用 Eclipse/CDT 调试 C++ 代码时更好地探索变量

c - C 中的指针及其值

c - 指向结构的指针,试图引用其数据成员 - C

C - sbrk(size) 返回有效指针,但 sbrk(0) 为负值

eclipse - 设置反汇编 View 颜色

makefile - 使 : *** multiple target patterns. 停止