Ver código fonte

move `static_assert`

blueloveTH 1 ano atrás
pai
commit
601c1029ce
2 arquivos alterados com 5 adições e 10 exclusões
  1. 0 10
      include/pocketpy/objects/base.h
  2. 5 0
      src/public/internal.c

+ 0 - 10
include/pocketpy/objects/base.h

@@ -1,10 +1,5 @@
 #pragma once
 
-#include <stdlib.h>
-#include <assert.h>
-#include <string.h>
-
-#include "pocketpy/common/utils.h"
 #include "pocketpy/pocketpy.h"
 
 typedef struct PyObject PyObject;
@@ -26,8 +21,3 @@ typedef struct py_TValue {
         c11_vec2i _vec2i;
     };
 } py_TValue;
-
-// 16 bytes to make py_arg() macro work
-static_assert(sizeof(py_CFunction) <= 8, "sizeof(py_CFunction) > 8");
-static_assert(sizeof(py_TValue) == 16, "sizeof(py_TValue) != 16");
-static_assert(offsetof(py_TValue, extra) == 4, "offsetof(py_TValue, extra) != 4");

+ 5 - 0
src/public/internal.c

@@ -22,6 +22,11 @@ void py_initialize() {
     bool is_little_endian = *(char*)&x == 1;
     if(!is_little_endian) c11__abort("is_little_endian != true");
 
+    // check py_TValue; 16 bytes to make py_arg() macro work
+    static_assert(sizeof(py_CFunction) <= 8, "sizeof(py_CFunction) > 8");
+    static_assert(sizeof(py_TValue) == 16, "sizeof(py_TValue) != 16");
+    static_assert(offsetof(py_TValue, extra) == 4, "offsetof(py_TValue, extra) != 4");
+
     MemoryPools__initialize();
     py_Name__initialize();