Browse Source

extern C in all headers for C++, static library

Kajetan Johannes Hammerle 3 years ago
parent
commit
697ae128ef
18 changed files with 137 additions and 1 deletions
  1. 8 0
      Compiler.h
  2. 8 0
      DataType.h
  3. 8 0
      Test.h
  4. 8 0
      Types.h
  5. 8 0
      libraries/Math.h
  6. 8 0
      libraries/Time.h
  7. 1 1
      meson.build
  8. 8 0
      tokenizer/File.h
  9. 8 0
      tokenizer/Token.h
  10. 8 0
      tokenizer/Tokenizer.h
  11. 8 0
      utils/ByteCodePrinter.h
  12. 8 0
      utils/Functions.h
  13. 8 0
      utils/SnuviUtils.h
  14. 8 0
      utils/Variables.h
  15. 8 0
      vm/Arrays.h
  16. 8 0
      vm/ByteCode.h
  17. 8 0
      vm/Operation.h
  18. 8 0
      vm/Script.h

+ 8 - 0
Compiler.h

@@ -1,10 +1,18 @@
 #ifndef COMPILER_H
 #define COMPILER_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "vm/ByteCode.h"
 
 ByteCode* cCompile();
 const char* cGetError();
 int cGetLine();
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

+ 8 - 0
DataType.h

@@ -1,6 +1,10 @@
 #ifndef DATATYPE_H
 #define DATATYPE_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdbool.h>
 
 #include "Types.h"
@@ -86,4 +90,8 @@ void gstsDelete();
 Structs* gstsGet();
 Struct* gstsAdd(const char* name);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

+ 8 - 0
Test.h

@@ -1,6 +1,14 @@
 #ifndef TEST_H
 #define TEST_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void tsStart(const char* path);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

+ 8 - 0
Types.h

@@ -1,6 +1,10 @@
 #ifndef TYPES_H
 #define TYPES_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdint.h>
 
 typedef int8_t int8;
@@ -8,4 +12,8 @@ typedef int16_t int16;
 typedef int32_t int32;
 typedef int64_t int64;
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

+ 8 - 0
libraries/Math.h

@@ -1,6 +1,14 @@
 #ifndef MATH_H
 #define MATH_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void lMathRegister();
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

+ 8 - 0
libraries/Time.h

@@ -1,6 +1,14 @@
 #ifndef TIME_H
 #define TIME_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void lTimeRegister();
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

+ 1 - 1
meson.build

@@ -23,7 +23,7 @@ mathDep = cc.find_library('m', required : true)
 
 args = ['-Wall', '-Wextra', '-pedantic', '-Werror', '-O3']
 
-library('lonely_tiger', 
+static_library('lonely_tiger', 
     sources: src,
     dependencies : mathDep,
     c_args: args)

+ 8 - 0
tokenizer/File.h

@@ -1,6 +1,10 @@
 #ifndef FILE_H
 #define FILE_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdbool.h>
 
 typedef void (*FileError)(const char*, ...);
@@ -12,4 +16,8 @@ int fRead();
 int fPeek();
 bool fReadIf(int c);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

+ 8 - 0
tokenizer/Token.h

@@ -1,6 +1,10 @@
 #ifndef TOKEN_H
 #define TOKEN_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef enum {
     T_VOID,
     T_INT32,
@@ -76,4 +80,8 @@ typedef enum {
 const char* tGetName(Token token);
 Token tFromName(const char* name);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

+ 8 - 0
tokenizer/Tokenizer.h

@@ -1,6 +1,10 @@
 #ifndef TOKENIZER_H
 #define TOKENIZER_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdbool.h>
 
 #include "Types.h"
@@ -21,4 +25,8 @@ const char* tReadString();
 int tGetMarker();
 void tReset(int marker);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

+ 8 - 0
utils/ByteCodePrinter.h

@@ -1,8 +1,16 @@
 #ifndef BYTECODEPRINTER_H
 #define BYTECODEPRINTER_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "vm/ByteCode.h"
 
 void btPrint(ByteCode* bt);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

+ 8 - 0
utils/Functions.h

@@ -1,6 +1,10 @@
 #ifndef FUNCTIONS_H
 #define FUNCTIONS_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdbool.h>
 
 #include "DataType.h"
@@ -43,4 +47,8 @@ bool gfsAdd(Function* f);
 bool gfsCall(Script* sc, int id);
 void gfsDelete();
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

+ 8 - 0
utils/SnuviUtils.h

@@ -1,10 +1,18 @@
 #ifndef SNUVI_UTILS_H
 #define SNUVI_UTILS_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdbool.h>
 
 bool isLetter(int c);
 bool isNumber(int c);
 bool isAllowedInName(int c);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

+ 8 - 0
utils/Variables.h

@@ -1,6 +1,10 @@
 #ifndef STRINGINTMAP_H
 #define STRINGINTMAP_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdbool.h>
 
 #include "DataType.h"
@@ -36,4 +40,8 @@ void vsReset(Variables* v);
 void vsEnterScope(Variables* v, Scope* s);
 void vsLeaveScope(Variables* v, Scope* s);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

+ 8 - 0
vm/Arrays.h

@@ -1,6 +1,10 @@
 #ifndef ARRAYS_H
 #define ARRAYS_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdbool.h>
 
 #include "DataType.h"
@@ -26,4 +30,8 @@ int asAllocate(SnuviArrays* as, int typeSize, int length);
 SnuviArray* asGet(SnuviArrays* as, int p);
 void asDeleteArray(SnuviArrays* as, SnuviArray* a, int p);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

+ 8 - 0
vm/ByteCode.h

@@ -1,6 +1,10 @@
 #ifndef BYTECODE_H
 #define BYTECODE_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "vm/Operation.h"
 
 typedef struct {
@@ -18,4 +22,8 @@ void bcAddBytes(ByteCode* bc, const void* data, int length);
 int bcGetAddress(ByteCode* bc);
 void bcInsertBytes(ByteCode* bc, const void* data, int length, int address);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

+ 8 - 0
vm/Operation.h

@@ -1,6 +1,10 @@
 #ifndef OPERATION_H
 #define OPERATION_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define OP_INTEGRAL(TYPE) OP_##TYPE##_INT32, OP_##TYPE##_INT64
 #define OP_NUMBER(TYPE) OP_INTEGRAL(TYPE), OP_##TYPE##_FLOAT
 #define OP_TYPE(TYPE) OP_NUMBER(TYPE), OP_##TYPE##_BOOL
@@ -74,4 +78,8 @@ typedef enum Operation {
     OP_CALL
 } Operation;
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

+ 8 - 0
vm/Script.h

@@ -1,6 +1,10 @@
 #ifndef SCRIPT_H
 #define SCRIPT_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdbool.h>
 
 #include "vm/Arrays.h"
@@ -40,4 +44,8 @@ bool sPushNullPointer(Script* sc);
 void* sCheckAddress(Script* sc, Pointer* p, int length);
 bool sGetPointerLength(Script* sc, Pointer* p, int32* length);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif