Files
scc/libs/sstream/include/scc_pos_log.h
zzy 4e2176b7f0 feat(compiler): 添加对裸机环境的支持并改进构建配置
- 更新README描述为C语言裸机环境的自举编译器
- 修改justfile中的构建命令,添加--dev参数并将输出文件名从scc.exe改为scc
- 在AST定义中添加SCC_AST_UNKNOWN节点类型
- 修复位置日志格式化中的类型错误
- 实现标准输出流支持,当输出文件为'-'时输出到控制台
- 支持基于环境变量LANG的语言本地化选择

fix(lexer): 改进标记打印功能

- 修复换行符的显示,将实际换行符显示为"\n"
- 改进文件输出逻辑,支持标准输出流

refactor(build): 更新cbuild工具的包含路径

- 将包含路径从"scc_libs"更改为"scc_include"

test: 添加简单的包含测试用例

- 新增测试文件tests/simple/12_include.c用于测试头文件包含功能
2026-02-26 16:07:19 +08:00

31 lines
1.5 KiB
C

#ifndef __SCC_POS_LOG_H__
#define __SCC_POS_LOG_H__
#include "scc_pos.h"
#include <scc_core.h>
extern logger_t __scc_usr_log;
#define SCC_POS_LOG(level, pos, fmt, ...) \
do { \
char _full_msg[LOGGER_MAX_BUF_SIZE]; \
int _n = snprintf_(_full_msg, sizeof(_full_msg), \
"%s:%u:%u: ", (pos).name, (pos).line, (pos).col); \
snprintf_(_full_msg + _n, sizeof(_full_msg) - _n, fmt, ##__VA_ARGS__); \
__scc_usr_log.handler(&__scc_usr_log, level, null, 0, null, "%s", \
_full_msg); \
} while (0)
#define SCC_DEBUG(pos, fmt, ...) \
SCC_POS_LOG(LOG_LEVEL_DEBUG, pos, fmt, ##__VA_ARGS__)
#define SCC_INFO(pos, fmt, ...) \
SCC_POS_LOG(LOG_LEVEL_INFO, pos, fmt, ##__VA_ARGS__)
#define SCC_WARN(pos, fmt, ...) \
SCC_POS_LOG(LOG_LEVEL_WARN, pos, fmt, ##__VA_ARGS__)
#define SCC_ERROR(pos, fmt, ...) \
SCC_POS_LOG(LOG_LEVEL_ERROR, pos, fmt, ##__VA_ARGS__)
#define SCC_FATAL(pos, fmt, ...) \
SCC_POS_LOG(LOG_LEVEL_FATAL, pos, fmt, ##__VA_ARGS__)
#endif /* __SCC_POS_LOG_H__ */