Category : global-variables

I have gstdsexample.so, a C++ library. Inside, it has two global variables that I’d like to share between the library and the main C program. pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; int *ptr; Test two scenarios. Scenario 1 sharedata.h #ifndef __SHARE_DATA_H__ #define __SHARE_DATA_H__ #include <stdio.h> #include <pthread.h> pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; int *ptr; #endif /* __SHARE_DATA_H__ */ ..

Read more