in the file main.c, i define
typedef struct
{
unsigned char A;
unsigned char B;
unsigned char C;
}TDATA_EXAMPLE;
TDATA_EXAMPLE Data_examples;
In the file events.c i want to modify a parameter of struct but i don't know how declare (extern ... ?)
Data_examples.A = 1;
Solved! Go to Solution.
Hi, @Albert_mtb
You can add the following code in event.c for external declaration:
typedef struct {
unsigned char A;
unsigned char B;
unsigned char C;
} TDATA_EXAMPLE;
extern TDATA_EXAMPLE Data_examples;
You can also create a new header.h file to contain the TDATA_EXAMPLE struct definition by adding the following code to event.c:
#include "header.h"
extern TDATA_EXAMPLE Data_examples;
header.h is as follows:
#ifndef __HEADER_H
#define __HEADER_H
typedef struct {
unsigned char A;
unsigned char B;
unsigned char C;
} TDATA_EXAMPLE;
#endif
I recommend using header file definitions for large projects.
Best regards, Alex
Thank you so much Alex
Best regards
Hi, @Albert_mtb
You can add the following code in event.c for external declaration:
typedef struct {
unsigned char A;
unsigned char B;
unsigned char C;
} TDATA_EXAMPLE;
extern TDATA_EXAMPLE Data_examples;
You can also create a new header.h file to contain the TDATA_EXAMPLE struct definition by adding the following code to event.c:
#include "header.h"
extern TDATA_EXAMPLE Data_examples;
header.h is as follows:
#ifndef __HEADER_H
#define __HEADER_H
typedef struct {
unsigned char A;
unsigned char B;
unsigned char C;
} TDATA_EXAMPLE;
#endif
I recommend using header file definitions for large projects.
Best regards, Alex