正在输入联合体示例代码

This commit is contained in:
Wang Boyang 2025-07-17 22:47:43 +08:00
parent 8b87cff2ee
commit 62f0b69744
11 changed files with 31 additions and 1 deletions

20
ex35/ex35.c Normal file
View File

@ -0,0 +1,20 @@
#include <stdio.h>
typedef enum {
TYPE_INT,
TYPE_FLOAT,
TYPE_STRING,
} VariantType;
struct Variant {
VariantType type;
union {
int as_integer;
float as_float;
char *as_string;
} data;
};
typedef struct Variant Variant;

View File

@ -1,5 +1,7 @@
# gcc $(pkg-config --cflags libbsd-overlay) hello.c -o hello $(pkg-config --libs libbsd-overlay)
CFLAGS=-isystem /usr/include/bsd -DLIBBSD_OVERLAY -g -O2 -Wall -Wextra -Isrc -rdynamic -DNDEBUG $(OPTFLAGS)
# CFLAGS=-isystem /usr/include/bsd -DLIBBSD_OVERLAY -g -O2 -Wall -Wextra -Isrc -rdynamic -DNDEBUG $(OPTFLAGS)
CFLAGS=$(pkg-config --cflags libbsd-overlay) -g -O2 -Wall -Wextra -Isrc -rdynamic -DNDEBUG $(OPTFLAGS)
LDLIBS = -lbsd -lm
LIBS=-ldl $(OPTLIBS)
PREFIX?=/usr/local

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -22,3 +22,11 @@ RadixMap *RadixMap_create();
void RadixMap_destroy(RadixMap *map);
void RadixMap_sort(RadixMap *map);
RMElement *RadixMap_find(RadixMap *map, uint32_t key);
int RadixMap_add(RadixMap *mao, uint32_t values);
int RadixMap_delete(RadixMap *map, RMElement *el);
#endif

Binary file not shown.

Binary file not shown.

Binary file not shown.