系统:KUbuntu11.04
调试错误:
g++ -g -Wall -O3 -D_LINUX_ -DMMAP_POPULATE -fstrict-aliasing -Wstrict-aliasing -D__x86_64__ -c word_count.cpp -o word_count.o -I../../include
In file included from ../../include/map_reduce.h:37:0,
from word_count.cpp:39:
../../include/stddefines.h: 在函数‘void get_time(timespec&)’中:
../../include/stddefines.h:86:19: 警告: variable ‘noskip’ set but not used [-Wunused-but-set-variable]
In file included from word_count.cpp:39:0:
../../include/map_reduce.h: 在成员函数‘int MapReduce<Impl, D, K, V, Container>::run(std::vector<MapReduce<Impl, D, K, V, Container>::keyval>&) [with Impl = WordsMR, D = wc_string, K = wc_word, V = long unsigned int, Container = hash_container<wc_word, long unsigned int, sum_combiner, wc_word_hash>]’中:
word_count.cpp:223:5:从此处实例化
../../include/map_reduce.h:202:5: 错误: 将‘const WordsMR’作为‘int WordsMR::split(wc_string&)’的‘this’实参时丢弃了类型限定 [-fpermissive]
make: *** [word_count.o] 错误 1
解决方法:
修改Makefile文件,将 -fpermissive 加进去,修改后如下:
-------------------------------------------
HOME = ../..
include $(HOME)/Defines.mk
LIBS += -L$(HOME)/$(LIB_DIR) -l$(PHOENIX)
WC_OBJS := word_count.o
PROGS := word_count
.PHONY: default all clean
default: all
all: $(PROGS)
word_count: $(WC_OBJS) $(LIB_DEP)
$(CXX) -fpermissive $(CFLAGS) -o $@ $(WC_OBJS) $(LIBS)
%.o: %.cpp
$(CXX) -fpermissive $(CFLAGS) -c {1}lt; -o $@ -I$(HOME)/$(INC_DIR)
clean:
rm -f $(PROGS) $(WC_OBJS)
注意:$CXX, rm开头必须要有"Tab"间隔符,不能有空格,否则调试出错!