Page 1 of 1

How to define an external macro.....

Posted: Wed Jun 21, 2006 11:27 am
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]

Posted: Wed Jun 21, 2006 11:44 am
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.

Posted: Thu Jun 22, 2006 5:17 am
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:

Posted: Thu Jun 22, 2006 6:02 am
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.