Automatically inserting filename & line number in logging statements of a C program
问题 I am writing a program for an embedded ARM processor in C . I would like to see the source filename and line number in the logging statements. As the compiled code has no knowledge of line numbers and source files, I am looking for ways to have this inserted automatically before / during the compile process. Are there any standard tools or compiler features that I can use for this? I am using GCC. For example: This is what I would write in the source file: log("<#filename#> <#linenumber#> :