_ File __,__ line __, function _ implement code tracking debugging (Linux C Programming http://bbs.linux-cn.com/archiver/tid-13793.html (come from)
[Color = #295200] [size = 14pt] [B] _ file __,__ line __, function _ implement code tracking and debugging (C Programming in Linux) [/B] [/size] [/color] first look at the simple initial code: Pay attention to the compiled and running results.
Root @ xuanfei-desktop :~ /Cpropram/2 # Cat global. h // header file
# Ifndef clobal_h
# Define global_h
# Include <stdio. h>
Int funca (void );
Int funcb (void );
# Endif
Root @ xuanfei-desktop :~ /Cpropram/2 # Cat funca. C // function
# Include "Global. H"
Int funca (void)
{
Printf ("this is function/N ");
Return 0;
}
Root @ xuanfei-desktop :~ /Cpropram/2 # Cat funcb. C // function B
# Include "Global. H"
Int funcb (void)
{
Printf ("this is function/N ");
Return 0;
}
Root @ xuanfei-desktop :~ /Cpropram/2 # gcc-wall funca. c funcb. C main. C // Compilation
Root @ xuanfei-desktop :~ /Cpropram/2 #./A. Out // run
This is main
This is Function
This is main
This is Function
This is main
It is difficult to see the error in the same result. Next we will use _ file __,__ line __,__ function _ to add the code to see if there is any difference.
Add _ file __,__ line __,__ function _ to mail. C.
Root @ xuanfei-desktop :~ /Cpropram/2 # Cat main. c
# Include "Global. H"
Int main (INT argc, char ** argv)
{
Printf ("% s (% d)-% S: This is main/N" ,__ file __,__ line __,__ function __);
Funca ();
Printf ("% s (% d)-% S: This is main/N" ,__ file __,__ line __,__ function __);
Funcb ();
Printf ("% s (% d)-% S: This is main/N" ,__ file __,__ line __,__ function __);
Return 0;
}
Root @ xuanfei-desktop :~ /Cpropram/2 # gcc-wall funca. c funcb. C main. c
Root @ xuanfei-desktop :~ /Cpropram/2 #./A. Out
Main. C (4)-Main: This is main
This is Function
Main. C (6)-Main: This is main
This is Function
Main. C (8)-Main: This is main
The above result main. C (4)-Main: This is main indicates that this is main printed in the fourth line of main function of Mian. C source code.
In this case, it is very convenient for programmers to correct their own programs!
To make it easier to use, we can implement macro definition in the global. H code.
Root @ xuanfei-desktop :~ /Cpropram/2 # Cat global. h
# Ifndef clobal_h
# Define global_h
# Include <stdio. h>
Int funca (void );
Int funcb (void );
# Define debugfmt "% s (% d)-% s"
# Define debugargs _ file __,__ line __,__ function __
# Endif
Root @ xuanfei-desktop :~ /Cpropram/2 # Cat funca. c
# Include "Global. H"
Int funca (void)
{
Printf (debugfmt "this is function/N", debugargs );
Return 0;
}
Root @ xuanfei-desktop :~ /Cpropram/2 # Cat funcb. c
# Include "Global. H"
Int funcb (void)
{
Printf (debugfmt "this is function/N", debugargs );
Return 0;
}
Root @ xuanfei-desktop :~ /Cpropram/2 # Cat main. c
# Include "Global. H"
Int main (INT argc, char ** argv)
{
Printf (debugfmt "this is main/N", debugargs );
Funca ();
Printf (debugfmt "this is main/N", debugargs );
Funcb ();
Printf (debugfmt "this is main/N", debugargs );
Return 0;
}
Root @ xuanfei-desktop :~ /Cpropram/2 # gcc-wall funca. c funcb. C main. c
Root @ xuanfei-desktop :~ /Cpropram/2 #./A. Out
Main. C (4)-mainthis is main
Funca. C (4)-funca this is function
Main. C (6)-mainthis is main
Funcb. C (4)-funcb this is function
Main. C (8)-mainthis is main
Root @ xuanfei-desktop :~ /Cpropram/2 #
This is to define the _ file __,__ line __, function _ macro to easily implement code tracking and debugging :)
Based on the transcript made by Zhou Lifa's Linux video tutorial, we recommend that you download and watch the video at the following link for your convenience.
[Size = 2] [color = # 0001ff] [url = http://blog.chinaunix.net/u/29321/showart_342131.html##size%10pt#zhou published a Linux video tutorial for downloading (occasionally updated) [/size] [/url] [/color] [/size] [color = # ff0102] [font = monospace]
[/Font] [/color] [color = # ff0102] If the above content is incorrect or has any shortcomings, I hope you can give comments or suggestions! Thanks :) Web Log: xuanfei.cublog.cn
[/Color] [color = # ff0102]
[/Color]
_ File __,__ line __, function _ implement code tracking debugging (Linux C Programming http://bbs.linux-cn.com/archiver/tid-13793.html (come from)
[Color = #295200] [size = 14pt] [B] _ file __,__ line __, function _ implement code tracking and debugging (C Programming in Linux) [/B] [/size] [/color] first look at the simple initial code: Pay attention to the compiled and running results.
Root @ xuanfei-desktop :~ /Cpropram/2 # Cat global. h // header file
# Ifndef clobal_h
# Define global_h
# Include <stdio. h>
Int funca (void );
Int funcb (void );
# Endif
Root @ xuanfei-desktop :~ /Cpropram/2 # Cat funca. C // function
# Include "Global. H"
Int funca (void)
{
Printf ("this is function/N ");
Return 0;
}
Root @ xuanfei-desktop :~ /Cpropram/2 # Cat funcb. C // function B
# Include "Global. H"
Int funcb (void)
{
Printf ("this is function/N ");
Return 0;
}
Root @ xuanfei-desktop :~ /Cpropram/2 # gcc-wall funca. c funcb. C main. C // Compilation
Root @ xuanfei-desktop :~ /Cpropram/2 #./A. Out // run
This is main
This is Function
This is main
This is Function
This is main
It is difficult to see the error in the same result. Next we will use _ file __,__ line __,__ function _ to add the code to see if there is any difference.
Add _ file __,__ line __,__ function _ to mail. C.
Root @ xuanfei-desktop :~ /Cpropram/2 # Cat main. c
# Include "Global. H"
Int main (INT argc, char ** argv)
{
Printf ("% s (% d)-% S: This is main/N" ,__ file __,__ line __,__ function __);
Funca ();
Printf ("% s (% d)-% S: This is main/N" ,__ file __,__ line __,__ function __);
Funcb ();
Printf ("% s (% d)-% S: This is main/N" ,__ file __,__ line __,__ function __);
Return 0;
}
Root @ xuanfei-desktop :~ /Cpropram/2 # gcc-wall funca. c funcb. C main. c
Root @ xuanfei-desktop :~ /Cpropram/2 #./A. Out
Main. C (4)-Main: This is main
This is Function
Main. C (6)-Main: This is main
This is Function
Main. C (8)-Main: This is main
The above result main. C (4)-Main: This is main indicates that this is main printed in the fourth line of main function of Mian. C source code.
In this case, it is very convenient for programmers to correct their own programs!
To make it easier to use, we can implement macro definition in the global. H code.
Root @ xuanfei-desktop :~ /Cpropram/2 # Cat global. h
# Ifndef clobal_h
# Define global_h
# Include <stdio. h>
Int funca (void );
Int funcb (void );
# Define debugfmt "% s (% d)-% s"
# Define debugargs _ file __,__ line __,__ function __
# Endif
Root @ xuanfei-desktop :~ /Cpropram/2 # Cat funca. c
# Include "Global. H"
Int funca (void)
{
Printf (debugfmt "this is function/N", debugargs );
Return 0;
}
Root @ xuanfei-desktop :~ /Cpropram/2 # Cat funcb. c
# Include "Global. H"
Int funcb (void)
{
Printf (debugfmt "this is function/N", debugargs );
Return 0;
}
Root @ xuanfei-desktop :~ /Cpropram/2 # Cat main. c
# Include "Global. H"
Int main (INT argc, char ** argv)
{
Printf (debugfmt "this is main/N", debugargs );
Funca ();
Printf (debugfmt "this is main/N", debugargs );
Funcb ();
Printf (debugfmt "this is main/N", debugargs );
Return 0;
}
Root @ xuanfei-desktop :~ /Cpropram/2 # gcc-wall funca. c funcb. C main. c
Root @ xuanfei-desktop :~ /Cpropram/2 #./A. Out
Main. C (4)-mainthis is main
Funca. C (4)-funca this is function
Main. C (6)-mainthis is main
Funcb. C (4)-funcb this is function
Main. C (8)-mainthis is main
Root @ xuanfei-desktop :~ /Cpropram/2 #
This is to define the _ file __,__ line __, function _ macro to easily implement code tracking and debugging :)
Based on the transcript made by Zhou Lifa's Linux video tutorial, we recommend that you download and watch the video at the following link for your convenience.
[Size = 2] [color = # 0001ff] [url = http://blog.chinaunix.net/u/29321/showart_342131.html##size%10pt#zhou published a Linux video tutorial for downloading (occasionally updated) [/size] [/url] [/color] [/size] [color = # ff0102] [font = monospace]
[/Font] [/color] [color = # ff0102] If the above content is incorrect or has any shortcomings, I hope you can give comments or suggestions! Thanks :) Web Log: xuanfei.cublog.cn
[/Color] [color = # ff0102]
[/Color]