SparkFun Forums 

Where electronics enthusiasts find answers.

Your source for all things Atmel.
User avatar
By SebaS
Hi! I'm back in town!!

I'm not much of a C programmer so I'm having some troubles....

I'got a macro and i want to use it in another module. How can I do it??

#define WEN var1

that's in module1.h

and I want to use WEN in module2.h

And I can't do it!!! :cry:

Any help is helpful :wink: [/code]
By jasonharper
You'd need to put:
Code: Select all
#include "module1.h"
somewhere in module2 prior to the point at which you first use the macro.
User avatar
By SebaS
Yes; I try to do that but an error flashes. And it's because I use functions from modulo2 in modulo1 and it says that there is an "ilegal function redefinition".
Believe me I'm getting MAD :twisted:
By jasonharper
Are you putting actual functions (not just function declarations) in your *.h files?

The normal structure for a multi-file C program is to have all functions in *.c files, each of which (except maybe for the top-level file) having a corresponding *.h file with declarations for the public functions & variables actually defined in the *.c file. Each *.c file #includes its own header file at the very top, along with the headers for each other *.c file containing items it references.