调试c++中的非链接头文件
Debug non-linking header files in C++
不知道有没有人有办法解决这个问题。
非常感谢!
在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;
}
相关文章:
- 无法链接文件系统库C++
- 如何在C++中链接 .a 文件
- 在为 Java 编译动态链接文件时,我应该选择哪些 g++ 参数
- Makefile 将在文件更改时链接文件,但不会重新编译更改的源文件
- CMake 从子目录和父目录链接文件
- 如何将GCC链接器固定地址添加到链接文件中
- 在GCC中链接.h文件
- 使用GDB中的多个链接文件进行调试
- visualstudio2010表达了不同项目中的链接文件
- 编译器是否会优化未使用的链接文件
- 尝试取消链接文件时编译 C++ 时出错
- 链接文件错误,VS 2015中的错误LNK2005
- 用C++中的链接文件编译错误
- Makefile未链接.o文件
- 如何链接.h文件中声明为extern的函数,以创建.dll文件
- 通过makefiles链接文件
- 未定义的引用错误,即使在链接c文件之后
- 多个链接c++文件
- 使用CMakeLists.txt链接c++文件
- 在c++中链接文件