move static_assert

This commit is contained in:
blueloveTH 2025-01-08 16:58:39 +08:00
parent 697312cae5
commit 601c1029ce
2 changed files with 5 additions and 10 deletions

View File

@ -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");

View File

@ -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();