Hi,
can somebody explain why am I getting segmentation fault on this program. It seams that the list that is initialized in clstouchcontext.h does not get recognized in clstouchcontext.cpp
Makefile is attached.
main.cpp:
#include "clstouchcontext.h"
#include <iostream>
int main () {
clsTouchContext* pContext = 0; //= GetContext ( iContextId ); //check iContextId
std::cout << "main here " << std::endl;
pContext->SetKey_clsTouchContext ( 0 , 0 , 0 , 0 , 0 );
return 0;
};
________________________________________________
clstouchcontext.cpp:
#include "clstouchcontext.h"
#include <iostream>
clsTouchContext::clsTouchContext( ){ }
clsTouchContext::~clsTouchContext() { }
int clsTouchContext:: SetKey_clsTouchContext ( int iKeyId , int iX , int iY , int iW , int iH ) {
std::cout << "clsTouchContext:: SetKey_clsTouchContext here " << m_lstAreas.size() <<" " << iKeyId << iX << iY << iW << iH << std::endl;
m_lstAreas.push_back ( 0 ); //loading key coordinates in list m_lstAreas
std::cout << "clsTouchContext:: SetKey_clsTouchContext here " << m_lstAreas.size() <<" " << iKeyId << iX << iY << iW << iH << std::endl;
return 0;
}
________________________________________________
clstouchcontext.h
#include <list>
class clsTouchContext {
public:
clsTouchContext( );
~clsTouchContext();
int SetKey_clsTouchContext ( int iKeyId , int iX , int iY , int iW , int iH );
protected:
std::list<int> m_lstAreas;
private:
};
______________________________________________
Makefile:
DEBUG = true
GLOBALCFLAGS = -march=i586 -W -Wall
DISTRIBUTE = -j3
GCCACHE = ccache
GPP = g++
PROFL = #-pg
EXE = ./touchtest
ifdef DEBUG
XTRAFLAGS = -g -D_DEBUG $(PROFL)
LINKFLAGS = $(PROFL) -lpthread
else
XTRAFLAGS = -O2
LINKFLAGS = -lpthread
endif
STATIC_LIB = libtouchscreen.a
# normal object compilation parameters
CFLAGS = -D_REENTRANT $(XTRAFLAGS) $(GLOBALCFLAGS) -fPIC -I./
#
SHARED_OBJS = main.o \
clstouchcontext.o
all: $(STATIC_LIB) $(EXE)
$(STATIC_LIB): $(SHARED_OBJS)
ar -r $(STATIC_LIB) $(SHARED_OBJS) > /dev/null 2>&1 || echo "FAILED"
$(EXE): $(STATIC_LIB)
$(GPP) $(STATIC_LIB) $(LINKFLAGS) -o $(EXE)
%.o: %.cpp %.h Makefile
$(GPP) $(CFLAGS) -c $<
%.o: %.cpp Makefile
$(GPP) $(CFLAGS) -c $<
clean:
@rm -f gmon.out compile.h .kdbgrc* *.o *.a *.am *.so *.so.* test core*