我想要一个简单的字符串表,它将存储一堆常量,我想"嘿!Lua那样做,让我使用一些函数!"
这主要是在lstring.h/lstring.c文件中(我使用的是5.2)
我将首先展示我很好奇的代码.它来自lobject.h
/*
** Header for string value; string bytes follow the end of this structure
*/
typedef union TString {
L_Umaxalign dummy; /* ensures maximum alignment for strings */
struct {
CommonHeader;
lu_byte reserved;
unsigned int hash;
size_t len; /* number of characters in string */
} tsv;
} TString;
/* get the actual string (array of bytes) from a TString */
#define getstr(ts) cast(const char *, (ts) + 1)
/* get the actual string (array of bytes) …Run Code Online (Sandbox Code Playgroud)