In vs2010 output the current file path and the current line number of the source file
- 2020-04-02 00:59:47
- OfStack
You see a question: in vs2010, how to output the current file path and the current line number of the source file.
I don't know, so I immediately searched the Internet and found the answer:
To summarize, they are used directly when they are useful, they are said to be system-predefined macros, but these macros are not defined in a file, they are defined by the compiler.
The above macros can be run in vc6.0 and vs2010, the output is as follows:
There is also a macro with the name of the output function, s/s, running in vs2010, but not defined in vc6.0, if called in the main function, output vmain.
I don't know, so I immediately searched the Internet and found the answer:
To summarize, they are used directly when they are useful, they are said to be system-predefined macros, but these macros are not defined in a file, they are defined by the compiler.
cout << __LINE__ << endl; //Output the line number of the statement
cout << __FILE__ << endl; //Output file name (including path)
cout << __TIME__ << endl; //Output current time
cout << __TIMESTAMP__ << endl; //Output timestamp
cout << __DATE__ << endl; //The output date
The above macros can be run in vc6.0 and vs2010, the output is as follows:
57
d:documents and settingsyxmy documentsvisual studio 2010projectsmatrixmat
rixmatrix.cpp
16:51:33
Mon Mar 12 16:51:32 2012
There is also a macro with the name of the output function, s/s, running in vs2010, but not defined in vc6.0, if called in the main function, output vmain.