Originally Posted by
ridgerunnersjw
I place them into a struct in file1.h
No, you didn't. You declared a struct that happens to have four members of the same names and types as those four global variables, but which have nothing to do with the global variables.
Since it is clear that you are insistent on having global variables even though I am not convinced that they are necessary for the problem that you're trying to solve, I'll just suggest this:
In file1.h:
Code:
struct swParams {
unsigned int switchHits[12];
unsigned int button;
boolean moreThanOneSwitch;
boolean moreThanOneSwitchTwoSec;
};
extern struct swParams switchParams;
void swMath(unsigned int *p);
Notice that I declared swMath as returning void. You do not want to return a struct swParams object because the one that you're working with is global. But honestly, I still don't see why you need a global variable. You can declare swMath like this instead:
Code:
void swMath(struct swParams *switchParams, unsigned int *p);
then in the main function:
Code:
struct swParams switchParams;
swMath(&switchParams, x);
Anyway, if you insist on a global variable, then in file1.c:
Code:
#include "file1.h"
struct swParams switchParams = {{0}, 0, F, F};