_ FUNCTION __, _ line __
Today, I have no intention of seeing a piece of code, which contains such a snippet:
If (! Interface) {err ("% s-error, can't find device for minor % d", _ FUNCTION __, subminor); retval =-enodev; goto exit ;}
What does _ function _ do? Rare (my level is not enough ~), Interesting ~
Later I found out that this is a macro definition associated with the GCC compiler. These macro definitions help to quickly locate the location where the Program Reports errors or warnings, number of rows in the file (_ line __)
Demo
/*************************************** * ********* Code writer: eofcode Date: 2014.08.17code file: macro_demo.ce-mail: [email protected] Code purpose: this code is a demo for how to use some special macros -- _ file _ function _ line____date __. it's funny and useful to use this macroto help you to debug. if there is something wrong with my code, please touch me by e-mail. **************************************** * *********/# include <stdio. h> void Hello (void) {printf ("_ file _: % S _ FUNCTION __: % S _ line __: % d _ date __: % s \ n ",__ file __,__ function __,__ line __,__ date _);} int main () {printf (" _ file __: % S _ FUNCTION __: % S _ line __: % d _ date __: % s \ n ",__ file __,__ function __,__ line __, __date _); Hello (); Return 0 ;}
Note that the macro definition here will not change according to the runtime environment. No matter which directory I am running this demo, the _ file _ printed characters will always prompt. /Hello. c thinks it is still the current directory. In fact, the runtime environment has changed.
Of course, these macro definitions are very helpful for debugging.