So the gist is to have a static global variable that can be modified by different executables. For example I have 2 different source files including the same dll.h:
dll.h
#include <iostream>
int globalCounter = 0;
__declspec(dllexport) void incrementCounter() {
globalCounter++;
std::cout << globalCounter << '\n';
}
Here are 2 source files that use this dll.h:
/////////// source 1
#include "dll.h"
int main()
{
incrementCounter();
}
////////// source 2
#include "dll.h"
int main()
{
for (int i = 0; i < 10; i++)
incrementCounter();
}
The 2 source files will be compiled to exes and ran. The behavior is that source 2 increments to 10 and source 1 resets to print 1. How can I make it so that first, I run source2 then source1 and source1 prints 11? If this idea is not good, then is there another way of accomplishing what I want without utilizing files? The dll nature of this project HAS to stay.