I have the problem described in the headline above. These are my files and their code:
run.c:
[...] // I think it's not relevant for the problem
declarations.h:
#ifndef DECLARATIONS_H
#define DECLARATIONS_H
#include <stdint.h>
#include <stdio.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <errno.h>
[...]
struct
{
int position;
int currentNumberOfMessages;
int numberOfProcesses;
char buf[MAX_PAYLOAD_LENGTH * MAX_SLOTS];
} mySharedMemory_sct = {0, 0, 0, '0'};
struct mySharedMemory_sct *myShMem_ptr;
[...]
#endif //DECLARATIONS_H
lib.h:
#ifndef LIB_H
#define LIB_H
#include "declarations.h"
#include <stdint.h>
#include <stdio.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <errno.h>
[...]
int init (int *argc, char **argv[])
{
/**
* map the shared memory into the process
*/
if ((myShMem_ptr = mmap(NULL, sizeof(mySharedMemory_sct), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) ==
MAP_FAILED)
{
printf("Error: %s\n", strerror(errno));
return EXIT_FAILURE;
}
/**
* increment the number of running processes called by the 'run'-process
*/
myShMem_ptr->numberOfProcesses += 1; <------- ERROR
[...]
return EXIT_SUCCESS;
}
[...]
#endif //LIB_H
For the line marked 'error' the compiler throws this error message:
"dereferencing pointer to incomplete type ‘struct mySharedMemory_sct’"
and highlights the '->' in "myShMem_ptr->numberOfProcesses += 1;" red as the problem.
I've read the other posts to this error message, but the problem causes were different (i think), so I haven't found a solution yet.
In advance: Thank you for your help!