【发布时间】:2014-10-24 04:26:02
【问题描述】:
您好,我正在使用 make 实用程序将结构 var 传递给另一个文件函数,我遇到错误 ppz 帮助修复它
1) var 的类型不完整 2) header.h:error: struct st 的前向声明
代码如下:
header.h
#include<iostream>
#include<stdio.h>
using namespace std;
void fn(struct st);
main.cpp
#include"header.h"
struct st
{
int x;
char s[10];
};
fn.cpp
#include"header.h"
void fn(struct st var)
{
cout<<var.x<<var.s<<endl;
}
制作文件
all: hello
hello: main.o fn.o
g++ main.cpp fn.cpp
main.o: main.cpp
g++ -c main.cpp
fn.o:fn.cpp
g++ -c fn.cpp
【问题讨论】: