0
点赞
收藏
分享

微信扫一扫

信号 和 槽

天使魔鬼 2024-11-06 阅读 3

废话不多说,直接上代码

#include <stdio.h>
#include <stdlib.h>

#define foreach_http_error				\
  _ (401, "401 error")					\
  _ (501, "501 error")

typedef enum
{
#define _(sym,string) HTTP_ERROR_##sym,
	foreach_http_error
#undef _
	HTTP_N_ERROR,
} http_reply_error_t;

static char *http_error_strings[] = {
#define _(sym,string) string,
	foreach_http_error
#undef _
};

const char *get_error(const int code) {
	return http_error_strings[code];
}

int main() {
	const char *err = get_error(HTTP_ERROR_401);
	printf("err string: %s\n", err);
	getchar();
	return 0;
}

举报

相关推荐

QT——信号和槽

笔记-信号和槽

Qt信号和槽

【Qt】信号和槽

QT_信号和槽

学习笔记_信号和槽

Qt基础-信号和槽函数

QT中的信号和槽

0 条评论