T
Tammy
Hello all,
I am wondering what is the best way to declare a struct to be used in
other c and c++ files. Such as for a C API that will be used by
others.
1. Declaring the typedef and the struct in the header file and
including this file in all source files that need it? For example:
mystruct.h
typedef mystruct mystruct_t;
struct mystruct {
int x;
char c;
};
-OR-
2. Declaring the typedef in a header file and declaring the struct in
the .c file ( I am not certain that this will work). For example:
mystruct.h
typedef mystruct mystruct_t;
mystruct.c
#include "mystruct.h"
struct mystruct {
int x;
char c;
};
......(other code using the structure)
-OR-
3. Other methods??
Thanks in advance for your help,
Tammy
I am wondering what is the best way to declare a struct to be used in
other c and c++ files. Such as for a C API that will be used by
others.
1. Declaring the typedef and the struct in the header file and
including this file in all source files that need it? For example:
mystruct.h
typedef mystruct mystruct_t;
struct mystruct {
int x;
char c;
};
-OR-
2. Declaring the typedef in a header file and declaring the struct in
the .c file ( I am not certain that this will work). For example:
mystruct.h
typedef mystruct mystruct_t;
mystruct.c
#include "mystruct.h"
struct mystruct {
int x;
char c;
};
......(other code using the structure)
-OR-
3. Other methods??
Thanks in advance for your help,
Tammy