mercredi 28 octobre 2015

Memory dump while executing code from custom namespace in C++

I have a simple library in my foo.cc file and a foo.h file with its interface. My goal is to use created library in both c and c++ programs. For c, I put interface between

#ifdef __cplusplus
extern "C" {
#endif

and

#ifdef __cplusplus
}
#endif

statements and it works perfectly fine. In order to use foo.cc in the c++ file, I put it into a namespace:

namespace ns {
    #include "foo.h"
}

This compiles without any errors or warnings, however when executing any function from foo.cc I get the error: "Floating point operation error (memory dump)". I build a c++ file executing:

g++ -c -Wall -O2 -std=c++11 foo.cc -o foo.o
g++ -c -Wall -O2 -std=c++11 my_prg.cc -o my_prg.o
g++ my_prg.o foo.o -o my_prg

Any ideas what I might be doing incorrectly?

(using LINUX)

Aucun commentaire:

Enregistrer un commentaire