调试c++中的非链接头文件

Debug non-linking header files in C++

本文关键字:链接 文件 c++ 调试      更新时间:2023-10-16

不知道有没有人有办法解决这个问题。

非常感谢!

在main.cpp中:

//
//  main.cpp
//  Chess
//
//  Created by Akshar Ramkumar on 9/29/16.
//  Copyright © 2016 Akshar Ramkumar. All rights reserved.
//
#include <iostream>
#include "DataStructures.hpp"

int main() {
    struct Piece {
        int Type;
        int x;
        int y;
        bool Captured;
        bool Color;
        char pictfile[7];
    };

    struct Piece All[32];
    setup(All);
    return 0;
}

DataStructures.hpp:

#ifndef DataStructures_hpp
#define DataStructures_hpp
void setup(struct Piece All[32]);

#endif

DataStructures.cpp:

//
//  Classes.cpp
//  Chess
//
//  Created by Akshar Ramkumar on 10/13/16.
//  Copyright © 2016 Akshar Ramkumar. All rights reserved.
//Pawn = 0
//Rook = 1
//Knight = 2
//Bishop = 3
//King = 4
//Queen = 5
struct Piece {
    int Type;
    int x;
    int y;
    bool Captured;
    bool Color;
    char pictfile[7];
};
void setup(struct Piece All[32]){
    int TypeArray[32]={0,0,0,0,0,0,0,0,1,1,2,2,3,3,4,5,0,0,0,0,0,0,0,0,1,1,2,2,3,3,4,5};
    int xValues[32]={0,1,2,3,4,5,6,7,0,7,1,6,2,5,3,4,0,1,2,3,4,5,6,7,0,7,1,6,2,5,3,4};
    int yValues[32]={1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7};

    for (int i=0;i<32;i++){
        All[i].Type = TypeArray[i];
        All[i].y = yValues[i];
        All[i].x = xValues[i];
        All[i].Color = true;
        All[i].Captured = false;

        if (i>15){
            All[i].Color = false;
        }

    }
}

我得到一个错误说:没有匹配的函数调用"Setup"在main.cpp。任何想法

代码的基本框架:

//
//  main.cpp
//  Chess
//
//  Created by Akshar Ramkumar on 9/29/16.
//  Copyright © 2016 Akshar Ramkumar. All rights reserved.
//
#include <iostream>
namespace DataStructures {
    struct Piece {
        int Type;
        int x;
        int y;
        bool Captured;
        bool Color;
        char pictfile[7];
    };
     void setup(Piece* pieces) {
          //TODO
     }
};
int main() {
    DataStructures::Piece All[32];
// Initialize All[32] here
    DataStructures::setup(All);
    return 0;
 }