jlab-sensing / Rocketlogger-Firmware

MIT License
0 stars 0 forks source link

Build/Install libipc as shared system library #4

Closed jmadden173 closed 2 years ago

jmadden173 commented 2 years ago

Makefiles are awful for subprojects. The simple fix is installing it as a shared library on unix to keep executable size down and not have duplicate statically linked libraries.

jmadden173 commented 2 years ago

In the process of creating shared libraries, I turned on warning flags for gcc and came up with all these warnings

cc -c -Isrc -Wall -Wextra -g  src/lora.c -o build/lora.o
In file included from src/lora.c:1:
src/lora.h:33:31: error: unknown type name ‘uint8_t’
   33 | int AT_SerialReceive(int bus, uint8_t buf[]);
      |                               ^~~~~~~
src/lora.h:4:1: note: ‘uint8_t’ is defined in header ‘<stdint.h>’; did you forget to ‘#include <stdint.h>’?
    3 | #include "uart.h"
  +++ |+#include <stdint.h>
    4 | //#include <rc/time.h>
src/lora.h:38:28: error: unknown type name ‘uint8_t’
   38 | int AT_SetNwkSKey(int bus, uint8_t *key);
      |                            ^~~~~~~
src/lora.h:38:28: note: ‘uint8_t’ is defined in header ‘<stdint.h>’; did you forget to ‘#include <stdint.h>’?
src/lora.h:40:28: error: unknown type name ‘uint8_t’
   40 | int AT_SetAppSKey(int bus, uint8_t *key);
      |                            ^~~~~~~
src/lora.h:40:28: note: ‘uint8_t’ is defined in header ‘<stdint.h>’; did you forget to ‘#include <stdint.h>’?
src/lora.c: In function ‘AT_SerialTransmit’:
src/lora.c:29:35: error: ‘uint8_t’ undeclared (first use in this function)
   29 |         res = rc_uart_write(bus, (uint8_t*)data, len);
      |                                   ^~~~~~~
src/lora.c:3:1: note: ‘uint8_t’ is defined in header ‘<stdint.h>’; did you forget to ‘#include <stdint.h>’?
    2 | #include <string.h>
  +++ |+#include <stdint.h>
    3 | 
src/lora.c:29:35: note: each undeclared identifier is reported only once for each function it appears in
   29 |         res = rc_uart_write(bus, (uint8_t*)data, len);
      |                                   ^~~~~~~
src/lora.c:29:43: error: expected expression before ‘)’ token
   29 |         res = rc_uart_write(bus, (uint8_t*)data, len);
      |                                           ^
src/lora.c:29:15: error: too few arguments to function ‘rc_uart_write’
   29 |         res = rc_uart_write(bus, (uint8_t*)data, len);
      |               ^~~~~~~~~~~~~
In file included from src/lora.h:3:
src/uart.h:95:5: note: declared here
   95 | int rc_uart_write(int bus, char* data, int bytes);
      |     ^~~~~~~~~~~~~
src/lora.c: At top level:
src/lora.c:35:31: error: unknown type name ‘uint8_t’
   35 | int AT_SerialReceive(int bus, uint8_t buf[]){
      |                               ^~~~~~~
src/lora.c:35:31: note: ‘uint8_t’ is defined in header ‘<stdint.h>’; did you forget to ‘#include <stdint.h>’?
src/lora.c: In function ‘AT_TestConnection’:
src/lora.c:53:9: error: unknown type name ‘uint8_t’
   53 |         uint8_t incoming[MAX_PAYLOAD_LENGTH] = {0};
      |         ^~~~~~~
src/lora.c:53:9: note: ‘uint8_t’ is defined in header ‘<stdint.h>’; did you forget to ‘#include <stdint.h>’?
src/lora.c:61:13: warning: implicit declaration of function ‘AT_SerialReceive’ [-Wimplicit-function-declaration]
   61 |         if (AT_SerialReceive(bus, incoming)){return RX_ERROR;}
      |             ^~~~~~~~~~~~~~~~
src/lora.c: In function ‘AT_CheckVersion’:
src/lora.c:76:9: error: unknown type name ‘uint8_t’
   76 |         uint8_t incoming[MAX_PAYLOAD_LENGTH] = {0};
      |         ^~~~~~~
src/lora.c:76:9: note: ‘uint8_t’ is defined in header ‘<stdint.h>’; did you forget to ‘#include <stdint.h>’?
src/lora.c: In function ‘AT_CheckID’:
src/lora.c:106:9: error: unknown type name ‘uint8_t’
  106 |         uint8_t incoming[MAX_PAYLOAD_LENGTH];
      |         ^~~~~~~
src/lora.c:106:9: note: ‘uint8_t’ is defined in header ‘<stdint.h>’; did you forget to ‘#include <stdint.h>’?
src/lora.c:118:39: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int *’ [-Wformat=]
  118 |                 printf("Device info: %s\n", incoming);
      |                                      ~^     ~~~~~~~~
      |                                       |     |
      |                                       |     int *
      |                                       char *
      |                                      %ls
src/lora.c: In function ‘AT_CheckDataRate’:
src/lora.c:126:9: error: unknown type name ‘uint8_t’
  126 |         uint8_t buf[MAX_PAYLOAD_LENGTH] = {0};
      |         ^~~~~~~
src/lora.c:126:9: note: ‘uint8_t’ is defined in header ‘<stdint.h>’; did you forget to ‘#include <stdint.h>’?
src/lora.c:138:36: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int *’ [-Wformat=]
  138 |         printf("Current datarate: %s\n", buf);
      |                                   ~^     ~~~
      |                                    |     |
      |                                    |     int *
      |                                    char *
      |                                   %ls
src/lora.c: At top level:
src/lora.c:142:28: error: unknown type name ‘uint8_t’
  142 | int AT_SetNwkSKey(int bus, uint8_t *key){
      |                            ^~~~~~~
src/lora.c:142:28: note: ‘uint8_t’ is defined in header ‘<stdint.h>’; did you forget to ‘#include <stdint.h>’?
src/lora.c:158:28: error: unknown type name ‘uint8_t’
  158 | int AT_SetAppSKey(int bus, uint8_t *key){
      |                            ^~~~~~~
src/lora.c:158:28: note: ‘uint8_t’ is defined in header ‘<stdint.h>’; did you forget to ‘#include <stdint.h>’?
src/lora.c: In function ‘AT_SetDataRate’:
src/lora.c:179:9: error: unknown type name ‘uint8_t’
  179 |         uint8_t buf[MAX_PAYLOAD_LENGTH] = {0};
      |         ^~~~~~~
src/lora.c:179:9: note: ‘uint8_t’ is defined in header ‘<stdint.h>’; did you forget to ‘#include <stdint.h>’?
src/lora.c:194:33: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int *’ [-Wformat=]
  194 |         printf("New data rate: %s\n", buf);
      |                                ~^     ~~~
      |                                 |     |
      |                                 |     int *
      |                                 char *
      |                                %ls
make: *** [Makefile:18: build/lora.o] Error 1