我们希望仅使用日志中的文件名、而不是使用__FILE__提供的整个文件路径。 借助 GCC、我们可以:
#define __FNAME__ (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
我们如何使用 C2000的 C28x 编译器完成类似任务?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
我们希望仅使用日志中的文件名、而不是使用__FILE__提供的整个文件路径。 借助 GCC、我们可以:
#define __FNAME__ (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
我们如何使用 C2000的 C28x 编译器完成类似任务?
没什么好说的
#define __FILENAME__ (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
printf("FILENAME: %s\r\n", __FILENAME__);
printf("FILE: %s\r\n", __FILE__);
和误差
**** Build of configuration CPU1_LAUNCHXL_FLASH for project empty_driverlib_project ****
"C:\\ti\\ccs1240\\ccs\\utils\\bin\\gmake" -k -j 12 all -O
Building file: "../empty_driverlib_main.c"
Invoking: C2000 Compiler
...
"../empty_driverlib_main.c", line 212: warning #225-D: function "__builtin_strrchr" declared implicitly
"../empty_driverlib_main.c", line 212: warning #43-D: operand types are incompatible ("int" and "char *")
Finished building: "../empty_driverlib_main.c"