引用了头文件,头文件已将包括了函数声明,问什么还是未定义标示符

ooax79 2016-03-19 11:04:56
这是什么原因那,这些函数只能在cpp再重新声明一下才能编译成功。.H的声明完全没有作用
...全文
7321 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
hezex 2020-04-11
  • 打赏
  • 举报
回复 1
不引用头文件,引用原文件就好了!!!
hezex 2020-04-10
  • 打赏
  • 举报
回复
我也出现了同样的问题 cpp:

#include "MathDrawPad.h"

HDC InitMathDrawPad()
{
	hAllwnd=GetForegroundWindow();
	hAllDC=GetDC(hAllwnd);
}
HDC InitMathDrawPad(HWND hwnd)
{
	hAllwnd=hwnd;
	hAllDC=GetDC(hAllwnd);
}

void SetDot(pos* p,COLORREF c)
{
	RECT rc;
	rc.left=p->x;
	rc.top=p->y;
	rc.right=p->x+1;
	rc.right=p->y+1;
	FillRect(hAllDC,&rc,(HBRUSH)&c);
}
void SetSomeDot(pos* p,COLORREF c,int len)
{
	for(int i=1;i<=len;i++) SetDot(&p[i],c);
}

void DrawLine(pos* bp,pos* ep,COLORREF c)
{
	int x=abs(bp->x-ep->x),y=abs(bp->y-ep->y);
	if(x>=y)
	{
		for(double i=0,j=0;i++,j+=y/x;i++)
		{
			pos p={(bp->x>=ep->x?i:-i),(bp->y-ep->y?j:-j)};
			SetDot(&p,c);
		}
	}
	else
	{
		for(double i=0,j=0;i++,j+=x/y;i++)
		{
			pos p={(bp->x>=ep->x?i:-i),(bp->y-ep->y?j:-j)};
			SetDot(&p,c);
		}
	}
}

void DrawCircle(pos* O,int r,COLORREF c)
{
	for(int i=-r;i<=r;i++)
	{
		pos p={i,sqrt(r*r-i*i)};
		SetDot(&p,c);
	}
	for(int i=-r;i<=r;i++)
	{
		pos p={i,-sqrt(r*r-i*i)};
		SetDot(&p,c);
	}
}

void ClosePad()
{
	ReleaseDC(hAllwnd,hAllDC);
}

void EndPad(void (*EndProc)())
{
	EndProc();
	ClosePad();
}
h:

/*
 * Name:		MathDrawPad
 * Copyright:	He Zhexi Personal Development
 * Author:		He Zhexi
 * Date: 10/04/20 10:44
 * Description:	This is the MathDrawPad's head file. MathDrawPad want to build an object to make easier to draw on the window.
 * So please when you're include to windows.h or cmath, think about have you include MathDrawPad.h?
 * If yes,please don't include windows.h or cmath. Because I have included the windows.h and cmath headfile.
 * If you know windows.h and you can use some(or many)API. I aslo write some function to use something in windows.h.
 * and You can find me LoadRe@163.com
 * This is my first head of big object. So if some where can be better. Welcome to find me in e-mail and tell the Improvement Scheme.
*/

#include <windows.h>
#include <cmath>

//The color macros

//First order color
#define COLOR_RED RGB(255,0,0)
#define COLOR_GREEN RGB(0,255,0)
#define COLOR_BLUE RGB(0,0,255)

//Second order color
#define COLOR_YELLO COLOR_RED|COLOR_GREEN
#define COLOR_PURPLE COLOR_RED|COLOLR_BLUE
#define COLOR_LIGHTBLUE COLOR_GREEN|COLOR_BLUE


//The var proclamations district
HDC hAllDC;
HWND hAllwnd;

//Some struct
#ifndef POS_H
#define POS_H
struct pos
{
	int x;
	int y;
};
#endif 

//Please init pad first. Else the pad won't work!
HDC InitMathDrawPad();
HDC InitMathDrawPad(HWND hwnd);

//Make init function easier
#define InitPad InitMathDrawPad

//The unit of the pad,dot.
//SetDot based on the FillRect function
void SetDot(pos* p,COLORREF c);

void SetSomeDot(pos* p,COLORREF c,int len); //This function will draw len dot.

//Lines based on the SetDot function.
void DrawLine(pos* bp,pos* ep,COLORREF c);

//Circle based on the SetDot,too.And it's also use function 'sqrt'
void DrawCircle(pos* O,int r,COLORREF c);

//Release the dc
void ClosePad();
void EndPad(void (*EndProc)());
test.cpp:

#include <MathDrawPad.h>
int main()
{
	InitPad();
	pos b={30,30},e={100,200};
	DrawLine(&b,&e,RGB(255,255,255));
	ClosePad();
	return 0;
}
有谁能帮我们一下啊——
qq_35585710 2019-10-20
  • 打赏
  • 举报
回复
重定解决方案目标也没用
qq_35585710 2019-10-20
  • 打赏
  • 举报
回复
#include<iostream>
#include <stdlib.h>
using namespace std;
constexpr auto length = 50;
typedef struct Lnode //Linknode类型声明
{
float a[7], b[7]; //a[]表示一个多项式的所有系数,b[]表示一个多项式的所有指数
struct Lnode *next;
}Linknode;
typedef struct Lnode1
{
float a[36], b[36];
struct Lnode1 *next;
}Linknode1;
void set(Linknode *&L, Linknode *&r, Linknode *&s)
{
L = (Linknode *)malloc(sizeof(Linknode)); //创建头结点
r = L;
L->next = NULL;
for (int i = 0; i < length; i++) //尾插法初始化链表,长度为50
{
s = (Linknode *)malloc(sizeof(Linknode));
r->next = s;
r = s;
}
r->next = L;
r = L->next;
s = L;
}
1>------ 已启动生成: 项目: 数据结构第一次实验1, 配置: Debug Win32 ------
1>E:\Visual Studio 2017\新建文件夹\Common7\IDE\VC\VCTargets\Microsoft.Cpp.WindowsSDK.targets(46,5): error MSB8036: 找不到 Windows SDK 版本8.1。请安装所需的版本的 Windows SDK 或者在项目属性页中或通过右键单击解决方案并选择“重定解决方案目标”来更改 SDK 版本。
1>已完成生成项目“数据结构第一次实验1.vcxproj”的操作 - 失败。
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========

我也是这种情况啊
高小瑾 2018-06-06
  • 打赏
  • 举报
回复
也可能是没在同一个命名空间
Tyler_Zx 2017-05-14
  • 打赏
  • 举报
回复
LInux下也会出现这样的问题,头文件没错的前提下基本上就两个情况,1 链接的库不对 2 条件编译的问题
  • 打赏
  • 举报
回复
我也出现这个问题了,你解决了嘛?
szn_409 2016-03-20
  • 打赏
  • 举报
回复
感觉不可能,贴代码看看
lm_whales 2016-03-19
  • 打赏
  • 举报
回复
可能是头文件有错误 也可能是条件编译问题 例如需要宏定义 例如 VC 开发的DLL 项目 会自动定义 一个宏,只在编译 时候有效  这样 头文件可以原封不动的那去,给使用此dll 的程序使用。 但是如果完全自己手动配置工程,可能就会编译不成功。
paschen 版主 2016-03-19
  • 打赏
  • 举报
回复
源文件中还要包含头文件,注意函数名字不要打错
ooax79 2016-03-19
  • 打赏
  • 举报
回复
引用 1 楼 paschen 的回复:
源文件中还要包含头文件,注意函数名字不要打错
所有函数都这样,,名字肯定没错,头文件也都包含了啊
paschen 版主 2016-03-19
  • 打赏
  • 举报
回复
引用 2 楼 ooax79 的回复:
引用 1 楼 paschen 的回复:
源文件中还要包含头文件,注意函数名字不要打错
所有函数都这样,,名字肯定没错,头文件也都包含了啊
那就不可能,没代码没真相
CharisJiang 2021-06-26
  • 举报
回复
@paschen 可能 我也遇到了 这样的情况。 想问下最后怎么 解决的?

65,192

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧