linux - how to print just filename without using __FILE__ in C -
linux - how to print just filename without using __FILE__ in C -
this question has reply here:
__file__ macro manipulation handling @ compile time 6 answersi want print filename beingness used in project. if utilize __file__
, prints entire path along file name long in case , disturbs log indents.
can please help how can print file name using mutual parameter across project.
in c code, might utilize instead of __file__
look basename(__file__)
; however, has disadvantage of calling basename
@ every occurrence.
alternatively, compile path/foo.c
command like
gcc -wall -c -g -dbase_file=\"foo\" path/foo.c
(you have generic make
rule giving that)
then utilize base_file
instead of __file__
in code.
with gcc, utilize __base_file__
instead of __file__
c linux
Comments
Post a Comment