error: ‘memcpy’ was not declared in this scope 解决

0. 在编译librangetree-v1.2(C++ 2D 范围树)时,出现 error: ‘memcpy’ was not declared in this scope 错误,原因是没有包含相关头文件

1. 错误如下:

[ghui@StuOS librangetree-v1.2]$ pwd
/home/Ghui/Desktop/librangetree-v1.2
[ghui@StuOS librangetree-v1.2]$ ls
bench  COPYING  doc  lrtypes.h  Makefile  ranget.h  test
[ghui@StuOS librangetree-v1.2]$ make
g++  ranget.h
make -C test
make[1]: Entering directory `/home/Ghui/Desktop/librangetree-v1.2/test'
g++ -Wall -Wextra -I ..   simple.cpp ../ranget.h   -o simple
In file included from test.h:8:0,
                 from simple.cpp:1:
../ranget.h: In instantiation of ‘void rangetree<point, data>::mergekids(rangetree<point, data>::pty*&, u32&, rangetree<point, data>::node*, rangetree<point, data>::node*) const [with point = short unsigned int; data = const char; u32 = unsigned int]’:
../ranget.h:417:65:   required from ‘void rangetree<point, data>::build() [with point = short unsigned int; data = const char]’
../ranget.h:114:9:   required from ‘void rangetree<point, data>::finalize() [with point = short unsigned int; data = const char]’
simple.cpp:11:16:   required from here
../ranget.h:535:30: error: ‘memcpy’ was not declared in this scope
      (rmax - r) * sizeof(pty));
                              ^
../ranget.h:539:30: error: ‘memcpy’ was not declared in this scope
      (lmax - l) * sizeof(pty));
                              ^
make[1]: *** [simple] Error 1
make[1]: Leaving directory `/home/Ghui/Desktop/librangetree-v1.2/test'
make: *** [all] Error 2


2. 在ranget.h头文件中添加#include <cstring>,如下:

#include <cstring>
#ifndef LIBRANGET
#define LIBRANGET

#include "lrtypes.h"


3. 修改后再次编译:

[ghui@StuOS librangetree-v1.2]$ make
g++  ranget.h
make -C test
make[1]: Entering directory `/home/Ghui/Desktop/librangetree-v1.2/test'
g++ -Wall -Wextra -I ..   simple.cpp ../ranget.h   -o simple
g++ -Wall -Wextra -I ..   x-search-before-fin.cpp ../ranget.h   -o x-search-before-fin
g++ -Wall -Wextra -I ..   period.cpp ../ranget.h   -o period
g++ -Wall -Wextra -I ..   random.cpp ../ranget.h   -o random
g++ -Wall -Wextra -I ..   individual.cpp ../ranget.h   -o individual
individual.cpp: In function ‘int main()’:
individual.cpp:14:26: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   tree.add(i, i, (u16 *) i);
                          ^
g++ -Wall -Wextra -I ..   identica.cpp ../ranget.h   -o identica
g++ -Wall -Wextra -I ..   mem-too-little.cpp ../ranget.h   -o mem-too-little
g++ -Wall -Wextra -I ..   signed.cpp ../ranget.h   -o signed
Running test simple... 
Running test x-search-before-fin... 
Running test period... 
Running test random... 
Running test individual... 
Running test identica... 
Running test mem-too-little... 
Running test signed... 

	All tests passed!

make[1]: Leaving directory `/home/Ghui/Desktop/librangetree-v1.2/test'
[ghui@StuOS librangetree-v1.2]$ 

By iomato

iomato.dev@Gmail.com

09:30 - 2013.01.05


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值