【发布时间】:2017-11-24 08:26:18
【问题描述】:
我正在编写动态内存分配程序。在这个程序中,我收到未定义符号_msize 的错误。我也包括 .请帮我解决这个问题。
/* Example of _msize */
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
void main()
{
long *buffer;
size_t size;
buffer = (long *)malloc(100 * sizeof(long));
size = _msize(buffer);
printf("The size of the buffer is %d\n", size);
}
【问题讨论】:
-
这是微软的非便携式产品。你在使用 MSVC 编译器吗?
-
_msize() 不是 C 的标准函数。它看起来像家常便饭。您需要包含正确的头文件才能使用它。查找 _msize() 它所在的头文件。旁注:不要使用不属于 C 标准的 void main()。
-
@LethalProgrammer..在
头文件中,这个函数已经存在。我也包括了那个。 digitalmars.com/rtl/stdlib.html#_msize -
您使用的头文件是用于您用于构建的环境吗? IE。匹配编译器,所有需要的库都隐式或显式链接。
-
MSVC 在
malloc.h中有_msize,您已将其包括在内。
标签: c compiler-errors turbo-c++