Problem extracting just a part of a matching pattern

Hello everyone, this is my first post so please give me a hand.
I apologize for my English, I'll try to be clear with my request.
I need to write a script (Bash) which finds all the variables defined in the file .h of the folder and then writes the name of the files .c where these variables are used.

I'd like to have a result like this:

MAXCAR
defined in xxx.h
used in yyy.c

The structure of the .h files is something like this:
#ifndef
#define XXX_H
.
.
#define MAXCAR 4
.
.
#endif

Of course the .c that uses the variable is something like this
#include "xxx.h"
.
.
.
int z=MAXCAR*4;

I hope I am clear with my request. I'll thank everyone who can help!

Hi, See if this helps.

 
ls *.h >files_h
while read filename
do
grep "#define" $filename | cut -d " " -f2 >variables.lst
while read var_name
do
Used_Files=`grep $var_name *.c |cut -d ":" -f1`
echo $var_name >>output
echo "Defined in" $filename >>output
echo "Used in" $Used_Files >>output
done <variables.lst
done<files_h