// OsdLib.cpp : Defines the entry point for the DLL application.
//#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
#include <iostream.h>
#include "stdafx.h"void bmp8_reverse (BYTE *pRgb, int width, int height)
{
BYTE *pTemp = (BYTE *)malloc (width * height);
BYTE *pDst = pTemp;
BYTE *pSrc = pRgb + (width * height);
ULONG bytes_in_line = width;
if (pDst == 0)
return;
for (int i=0; i<height; i++)
{
pSrc -= bytes_in_line;
memcpy (pDst, pSrc, bytes_in_line);
pDst += bytes_in_line;
}
memcpy (pRgb, pTemp, width * height);
free (pTemp);
}
--------------------Configuration: OsdLib - Win32 Debug--------------------
Compiling...
OsdLib.cpp
F:\Delphi Project\OSDDLL\OsdLib\OsdLib.cpp(15) : error C2065: 'malloc' : undeclared identifier
F:\Delphi Project\OSDDLL\OsdLib\OsdLib.cpp(28) : error C2065: 'free' : undeclared identifier
Error executing cl.exe.OsdLib.obj - 2 error(s), 0 warning(s)
我都加了
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
#include <iostream.h>为什么还老说malloc 和 free:
undeclared identifier?
//#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
#include <iostream.h>
#include "stdafx.h"void bmp8_reverse (BYTE *pRgb, int width, int height)
{
BYTE *pTemp = (BYTE *)malloc (width * height);
BYTE *pDst = pTemp;
BYTE *pSrc = pRgb + (width * height);
ULONG bytes_in_line = width;
if (pDst == 0)
return;
for (int i=0; i<height; i++)
{
pSrc -= bytes_in_line;
memcpy (pDst, pSrc, bytes_in_line);
pDst += bytes_in_line;
}
memcpy (pRgb, pTemp, width * height);
free (pTemp);
}
--------------------Configuration: OsdLib - Win32 Debug--------------------
Compiling...
OsdLib.cpp
F:\Delphi Project\OSDDLL\OsdLib\OsdLib.cpp(15) : error C2065: 'malloc' : undeclared identifier
F:\Delphi Project\OSDDLL\OsdLib\OsdLib.cpp(28) : error C2065: 'free' : undeclared identifier
Error executing cl.exe.OsdLib.obj - 2 error(s), 0 warning(s)
我都加了
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
#include <iostream.h>为什么还老说malloc 和 free:
undeclared identifier?
解决方案 »
- 编译出现这个,error C2440: '=' : cannot convert from 'unsigned short *' to 'unsigned short [20]'如何解决
- 关于TAB control子窗中控件间的相互访问
- AfxLoadString()使用时,系统说函数未声明
- 请问用VC可以读入Excel文件的内容吗?
- 关于自定义消息!
- 问一弱智问题,bmp文件由四部分(文件头、位图信息头、颜色信息和图形数据)组成,这是vc++的杰作,还是操作系统干的??
- 一个简单的问题!请教。急、急
- 想实现windows画图软件那样显示像素坐标的功能
- 怎样在两个类之间传递消息?
- 我现在用vector存储了需要读取的内容,想检测存储的内容是否正确
- 谁有逆波兰式的原理说明,不要程序,只要说明文档,给100分
- 为什么CEdit只能输入256个字符啊。不是说可以输入32k吗?请赐教,谢谢!!!!
直接将malloc的声明写出来试试:
在你的程序前加:void *malloc( size_t size );
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
#include <iostream.h>
就是说:编译器第一个找stdafx.h头文件,然后处理stdafx.h后面的头文件,stdafx.h放在最后,前面的头文件都被忽略了,产生了未定义的错误。
不过在Project->Setting->c/c++->Category->Procompile Headers选Not using precompelier header,那么stdafx.h放在那里都无所谓,编译可以通过!
发现是C/C++ -》 Catetgory -》 General,这个地方我什么也没有改,就是新建DLL项目后就这样的多谢啦