Here's how you give modules access to types and declarations in other modules:
Code:
/* mystruct.h */
#ifndef MYSTRUCT_H
#define MYSTRUCT_H
typedef unsigned char byte;
/* byte is a synonym for "unsigned char" */
typedef struct _mystruct_t
{
byte a,b;
} mystruct_t;
/* mystruct_t is a synonym for "struct _mystruct_t" */
void print_mystruct(const mystruct_t *ms);
/* function delcaration so other modules can call this function */
#endif /* MYSTRUCT_H */
Code:
/* mystruct.c */
#include <stdio.h>
#include "mystruct.h"
void print_mystruct(const mystruct_t *ms)
{
printf("%d, %d\n",ms->a, ms->b);
}
Code:
/* main.c */
#include "mystruct.h"
int main (void)
{
mystruct_t ms;
ms.a = 1;
ms.b = 2;
print_mystruct(&ms);
return 0;
}
gg