只打印文名

CMakeLists.txt

c 复制代码
set(CMAKE_C_FLAGS "-O0 -ggdb -D__NOTDIR_FILE__=$(notdir $<)")
// set(CMAKE_C_FLAGS "-O0 -ggdb -D__NOTDIR_FILE__=$(notdir $<) -D__FILENAME__=$(subst $(dir $<),,$<)")

C文件

c 复制代码
#include <stdio.h>

#ifdef __NOTDIR_FILE__
#define M2STR(x) #x
#define M2STR_IMPL(x) M2STR(x)
#define __BFILE__ M2STR_IMPL(__NOTDIR_FILE__)
#else
#define __BFILE__ __FILE__
#endif

void hello()
{
	printf("[%s:%s: %d] hello word\n", "123123", __BFILE__, __LINE__);
}

结果

c 复制代码
liuwen@liuwen-VirtualBox:~/test/cmake/02-1-use_static_lib/build$ ./static_use
[123123:hello.c: 18] hello word
相关推荐
万粉变现经纪人16 小时前
如何解决 pip install -r requirements.txt 私有索引未设为 trusted-host 导致拒绝 问题
开发语言·python·scrapy·flask·beautifulsoup·pandas·pip
qq_4798754316 小时前
C++ std::Set<std::pair>
开发语言·c++
云知谷18 小时前
【C++基本功】C++适合做什么,哪些领域适合哪些领域不适合?
c语言·开发语言·c++·人工智能·团队开发
l1t19 小时前
DeepSeek辅助利用搬移底层xml实现快速编辑xlsx文件的python程序
xml·开发语言·python·xlsx
C_Liu_21 小时前
C++:list
开发语言·c++
my rainy days21 小时前
C++:友元
开发语言·c++·算法
小梁努力敲代码21 小时前
java数据结构--List的介绍
java·开发语言·数据结构
云知谷1 天前
【HTML】网络数据是如何渲染成HTML网页页面显示的
开发语言·网络·计算机网络·html
从孑开始1 天前
ManySpeech.MoonshineAsr 使用指南
人工智能·ai·c#·.net·私有化部署·语音识别·onnx·asr·moonshine
YuanlongWang1 天前
C# 中,依赖注入(DI)的实现方式
c#