what that single file would look like:
// includes: (proyect includes with "" and system includes with <>)
#include "a.h"
...
#include "headers/n.h"
...
// system includes:
#include <stdio.h>
...
// structs:
typedef struct {
typeData variable_name1;
...
typeData variable_nameN;
struct name_type* var_name;
} A;
...
typedef struct {
typeData variable_name1;
...
typeData variable_nameN;
struct name_type* var_name;
} N;
// alias:
typedef oldType newType;
...
typedef char* String;
// prototypes:
void fuction1(A* param);// prototype
...
// implementations:
N* fuctionN(int param1, char param2);// prototype
// functions on structs:
void function1(A* param) {
...
}
N* fuctionN(int param1, char param2){
...
}
remember:
typedef oldType newType;
It is to define aliases, to write something easier and invoke the same thing, it is a syntactical replacement
with # preprocessor directives
The following example defines a symbol that is unique:
#ifndef UNIQUE_NAME_FILE_H
#define UNIQUE_NAME_FILE_H
typedef char* String; // other alias for example
// Structure representing a Aname
typedef struct {
String text;
typeData field1;
int field2;
} Aname;
#endif // UNIQUE_NAME_FILE_H
You define structs in a .h, function implementations in a .c, and prototypes functions along with the #includes in a .h
complete example
#include <stdio.h>
// Function prototype
int add(int a, int b);
int main() {
int result = add(5, 3);
printf("the addition is: %d\n", result);
return 0;
}
// Implementation
int add(int a, int b) {
return a + b;
}
The single file extension is .c (.h is for sharing responsibility and neatness)
example:
1 single file:
https://gitlab.com/com.leibnix/allinone
organized (several files):