【发布时间】:2014-10-18 19:16:06
【问题描述】:
在 ubuntu 12.04 LTS(64 位)上编译以下 makefile 时遇到此错误:
Ana.cxx:21:46: error: cast from ‘void*’ to ‘int’ loses precision [-fpermissive]
在这一行:
21 : TThread::Printf("Start of Ana %x \n" ,(int)ptr);
这是生成文件:
ObjSuf = o
SrcSuf = cxx
DllSuf = so
ExeSuf =
OutPutOpt = -o
CXXFLAGS = -g -Wall -fPIC -DOSF1
CXX = g++
CCFLAGS = -g -Wall -DOSF1
CC = gcc
LD = g++
LDFLAGS = -g
SOFLAGS = -shared
ROOTCFLAGS := $(shell root-config --cflags) -DFILL_ON_FLY
ROOTLIBS := $(shell root-config --libs) -lNew -lThread -lMinuit -lPhysics
ROOTGLIBS := $(shell root-config --glibs) -lNew -lThread
EVENTO = BINAEvent.$(ObjSuf) Ana.$(ObjSuf) BINAEventDict.$(ObjSuf) mwpc_software.o tcpip.o Genbood.o
EVENTS = BINAEvent.$(SrcSuf) Ana.$(SrcSuf) BINAEventDict.$(SrcSuf) mwpc_software.c tcpip.c Genbood.c
EVENTLIB = $(ROOTGLIBS)
EVENTEXE = ana
OBJS = $(EVENTO)
.SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)
.PHONY: Aclock Hello Tetris
$(EVENTEXE): $(OBJS)
$(LD) $^ $(ROOTLIBS) $(OutPutOpt) $@
@echo "$@ done"
clean:
@rm -f $(OBJS) core *~ *Dic* ana *.o
.SUFFIXES: .$(SrcSuf)
BINAEvent.$(ObjSuf): BINAEvent.h
BINAEventDict.$(SrcSuf): BINAEvent.h BINAEventLinkDef.h
@echo "Generating dictionary $@..."
@rootcint -f $@ -c $^
.$(SrcSuf).$(ObjSuf):
$(CXX) $(CXXFLAGS) $(ROOTCFLAGS) -c $<
.c.$(ObjSuf):
$(CXX) $(CXXFLAGS) $(ROOTCFLAGS) -c $<
投射这个的正确方法是什么?
提前致谢。
【问题讨论】:
-
试试
(unsigned int)ptr或(unsigned long)ptr
标签: c++ c gcc casting makefile