C and your own libraries

On way

This short tutorial is how to make your own libraries in C.

To have a mockup we - in the end - make an Arduino library out of it that you can install

Scope rules

Scope rules is about visibility.

Functions and variables that are NOT protected can be accessed from your whole program, even if you are providing them by a library.

Example 1 - standard scope rules: no protection

In teh code below ,

main.c                      lib.h                    lib.c
-------------------------------------------------------------------
#include "lib.h"            #indef LIBH              #include "lib.h"
                            #define LIBH             
void test(void)             int libFct(void);        int secret(void)
{                           #endif                   {
int r;                                                  return 44;
  r = libFct();                                      }   
}                                                    
                                                     int libFct(void) 
                                                     {
                                                        return secret(); 
                                                     }