title: exposing static variable through an inline function
body: <p>In my C code I want to expose static variables through inline functions , and this way avoid using 'extern' attribute, kind of OOP in standard C. However I cant compile it. Consider the following code:</p>
  
  <pre><code>$ cat object.h
  inline int get_value(int index);
  $ cat object.c
  #include "object.h"
  static int data_array[32];
  
  inline int get_value(int index) {
      return data_array[index];
  }
  $ cat app.c 
  #include "object.h"
  void main(void) {
      int datum;
  
      datum=get_value(8);
  }
  $ gcc -c object.c
  object.c:5:9: warning: ‘data_array’ is static but used in inline function ‘get_value’ which is not static
    return data_array[index];
           ^
  $ ls -l object.o
  -rw-rw-r-- 1 niko niko 976 Aug 30 15:56 object.o
  $ gcc -c app.c
  In file included from app.c:1:0:
  object.h:1:12: warning: inline function ‘get_value’ declared but never defined
   inline int get_value(int index);
              ^
  $ ls -l app.o
  -rw-rw-r-- 1 niko niko 1368 Aug 30 15:56 app.o
  $ gcc -o app app.o object.o
  app.o: In function `main':
  app.c:(.text+0xe): undefined reference to `get_value'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>Is it possible to access static variables somehow outside the file they have been declared through an inline function, that would be inlined in every .c file it is being used? Of course I can just declare the variable 'extern':</p>
  
  <pre><code>extern int data_array[];
  </code></pre>
  
  <p>and reference it directly but I want to do it through a function to simulate OOP in C without the overhead of a function call.</p>