how can i send an entire class from one process to another avoiding serialization? [closed]

StackOverflow https://stackoverflow.com/questions/20671843

  •  19-09-2022
  •  | 
  •  

Question

During my free-time programming i have encountered a problem.

Let us say, there is a large program A.cpp written by me and there is file B.cpp generated by bison+flex. During my run of program A i want to execute a parser (B) and then return a very complex object to A.

Are there any ways to perform this task, other then serializing the class into the pipe?

UPD The problem with serialization is simple: i just can't link boost libraries with my .cpp.

I have tried to reinstall libboost-dev 1.46, but linker keeps shouting, that references aren't met.

My code looks like this:

A.cpp
class blah {
  void read () {
      yyparse();
      arch >> *this;
  }
}

B.cpp:
int main() {
   yyparse(); // yacc parsing
   arch << result;
}

My makefile looks like this:

bison -d -v reader.y
cp reader.tab.c bison.c
cmp -s reader.tab.h tok.h || cp reader.tab.h tok.h
g++ -O2 -std=c++0x -w -l boost_serialization  -c bison.c -o bison.o
flex -d reader.lex
cp lex.yy.c lex.c
g++ -O2 -std=c++0x -w -l boost_serialization  -c lex.c -o lex.o
g++ -O2 -std=c++0x -w -l boost_serialization  -c reader.cpp -o main.o
g++ -O2 -std=c++0x -w -l boost_serialization  bison.o lex.o main.o -o reader -lfl
Was it helpful?

Solution

If the data has to pass across process boundaries then you cannot avoid serializing the data into a transportable format. Especially if the data contains any pointers/references to other memory, or even to its own internal members, since those pointers/references would not be valid in another process's address space.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top