Saturday, March 15.

Header Ads

Colorful+Black+Friday+Discount+Leaderboard+Ad

_LINE_and_FILE_Predefined Identifier of Compiler

Muscle+Inc.+%25282%2529

_LINE_and_FILE_Predefined%20Identifier%20of%20Compiler

_LINE_and_FILE_Predefined Identifier of Compiler

ये दोनों Identifiers Compiler में पहले से ही Defined किये गए है | _LINE_Identifier में Currently Compile हो रही Line का Number होता है और _FILE_Identifier में Currently Compile हो रही File का नाम होता है | इसे हम निम्न Program द्वारा समझ सकते हैं |

 

Program


// File : Macro.c
#include <stdio.h>
#include <conio.h>
#define MAX 100
void main(void)
{
#if MAX > 99
printf("Name of the Program File is %s", __FILE__ );
printf("\n");
printf("The Line being Compiled is %d", __LINE__);
#else
#error You have defined the MAX Macro Less than 100"
#endif
getch();
}

Output

Name of the Program File is Macro.c
The Line being Compiled is 10

यदि हम चाहें , तो इन दोनों Compiler Identifiers के मात्र Change कर सकते हैं | यानी हम चाहें तो _LINE के Number की शुरुआत 100 Number से भी कर सकते हैं और _FILE_Identifier में किसी दूसरी File का नाम भी प्रदान कर सकते हैं | इसे समझने के लिए निम्न Program देखते हैं |

Program


#include <stdio.h>
#include <conio.h>
#line 100 "inline.cpp"
#define MAX 100
void main(void)
{
#if MAX > 99
printf("Name of the Program File is %s", __FILE__ );
printf("\n");
printf("The Line being Compiled is %d", __LINE__);
#else
#error You have defined the MAX Macro Less than 100"
#endif
getch();
}

#Line Macro #include Macro की तरह काम करता है | इसके आगे जिस File का नाम दिया जाता है , Program उस File को भी Expand करता है और हमें Output में ये बताता है की जो Line हमने इस Program में Print की है , वह Line Originally inline.cpp File से आई है | सामान्यतया इस Directive का प्रयोग उन Utility Programs में किया जाता है , जो C के Code को Output के रूप में Produce करना चाहते है |


 

No comments

Post Top Ad

Post Bottom Ad