diff --git a/main/main.cpp b/main/main.cpp index 8b085d4..d812c4f 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1,5 +1,6 @@ #include "../src/SharedMemory.h" int main() { - return test(); + shared_memory_init(); + //return main(); } \ No newline at end of file diff --git a/src/SharedMemory.cpp b/src/SharedMemory.cpp index 367b123..551e997 100644 --- a/src/SharedMemory.cpp +++ b/src/SharedMemory.cpp @@ -1,3 +1,5 @@ +#include +#include #include "SharedMemory.h" //Shared-Memory-Segment erstellen oder öffnen – shmget() @@ -7,12 +9,12 @@ void shared_memory_init(){ //Ein Shared-Memory-Segment abfragen, ändern oder löschen – shmctl() void delet_shared_memory(){ - int shmctl(memory_id, IPC_RMID, 0); + memory_id = shmctl(memory_id, IPC_RMID, 0); } //Shared-Memory-Segment an einen Prozess anbinden (attach) – shmat() -void attach_process(char *myProcess){ - if(( myProcess = shmat( memmory_id, (char *)0, 0 )) < (char *)0 ){ +void attach_process(void *myProcess){ + if(( myProcess = shmat( memory_id, (char *)0, 0 )) < (char *)0 ){ perror("Fehler beim Ankoppeln des gemeinsamen Speicher Segments"); exit(-1); } diff --git a/src/SharedMemory.h b/src/SharedMemory.h index 471cfe5..bf09c50 100644 --- a/src/SharedMemory.h +++ b/src/SharedMemory.h @@ -6,7 +6,7 @@ #include //ID-Speicherbereich -#define int memory_id +extern int memory_id; //Größe des Speicherbereichs hier 8MB (8000) #define SHMMAXSIZE 8000 @@ -18,7 +18,7 @@ void shared_memory_init(); void delet_shared_memory(); //Shared-Memory-Segment an einen Prozess anbinden (attach) – shmat() -void attach_process(char *myProcess); +void attach_process(void *myProcess); //Ein Shared-Memory-Segment loslösen – shmdt() void release_memory(); diff --git a/test/test_demo.cpp b/test/test_demo.cpp index cc7e234..23ec771 100644 --- a/test/test_demo.cpp +++ b/test/test_demo.cpp @@ -3,4 +3,5 @@ TEST_CASE("Demo test") { REQUIRE(test() == 42); -} \ No newline at end of file +} +