Ja.
Du machst ein neues Modul: modul.h und modul.c
In modul.h stehen die Deklarationen von Dingen, die ausserhalb des Moduls bekannt sein sollen und benutzt werden
Code:
#ifndef _MODUL_H_
#define _MODUL_H_
#define BLAH1 ...
#define BLAH2(x) ...
extern char data1;
extern long data2;
extern char foo1 (long a);
extern long foo2 (char a);
#endif
In modul.c stehen die Definitionen dazu:
Code:
#include "modul.h"
static void foo_local();
char data1 = 12;
long data2;
char foo1 (long a)
{
...
}
long foo2 (char a)
{
BLAH2 (123);
...
}
static void foo_local()
{
...
}
Alle Module werden mit
avr-gcc -c modul.c -o modul.o [more-options]
übersetzt und dann zu einem elf zusammen gebunden.
Verwendung wie gewohnt
Code:
#include "modul.h"
main ()
{
if (data1 == 'x')
c = foo1(12345);
...
}
Lesezeichen