हिंदी माध्यम नोट्स
Categories: C Language in hindi
Preprocessor : Compiler Control Directives in hindi कम्पाइलर कण्ट्रोल डायरेक्टिव क्या है c कंप्यूटर भाषा में हिंदी में
कम्पाइलर कण्ट्रोल डायरेक्टिव क्या है c कंप्यूटर भाषा में हिंदी में Preprocessor : Compiler Control Directives in hindi :-
जब किसी large प्रोग्राम को run करते है तभी कुछ प्रॉब्लम आती है :-
1. जब किसी प्रोग्राम मे macro को define किया जाता है|तो ये पता लगाना मुश्किल है की macro define होता है या नहीं |
2.जब कोई यूजर दो अलग अलग कंप्यूटर के लिए प्रोग्राम बनता है तब कुछ lines की जरुरत होती उन प्रोग्राम को दो दो अलग अलग कंप्यूटर मे run करने के लिए|
3.जब हम अलग अलग कस्टमर के लिए प्रोग्राम बनाते है तब केवल एक प्रोग्राम उन दोनों कस्टमर्स के लिए बनाना पड़ता है |
इन सभी प्रॉब्लम का एक solution होता है अलग अलग प्रोग्राम को develop करना अलग अलग condition के लिए |
या फिर एक प्रोग्रम को develop करना जिसमे कई ऑप्शनल code होगे और किसी condition के फॉलो होंव पर control उए sepcific code पर मूव हो जायेगा |इस प्रोसेस को Compiler Control Directives कहते है |इस प्रोसेस मे lines को switch on और off कर सकते है |
Condition 1
इस प्रकार मे condition को macro मे define की जाती है |इस condition मे macro हमेशा declare होगा जो की condition expression हो hold करेगा |जैसे
#include “filename “
#ifndef MACRO_NAME
#define MACRO_NAME 1
#endif
इस syntax मे, file name उस file का नाम है जिसमे MACRO_NAME की डेफिनिशन होती है |
#ifndef MACRO_NAME statement से macro_name की definition को file _name मे search होती है |अगर MACRO_NAME की definition file name मे नहीं होती तब ‘#ifndef’ और ‘#endif’ के बीच की सभी statements perform होगी |
और अगर MACRO_NAME की definition मिलती है तब macro statement का declartion नहीं होगा |
Condition 2
जब किसी प्रोग्राम को सभी कंप्यूटर के लिए पोर्टेबल बनाने के लिए इस तरह के प्रोग्रामिंग का use करेगे |इअका syntax है :-
main()
{
statement 1;
statement 1;
statement 2;
#ifdef MAC_BOOK
{
statement for portabality;
}
else
{
statement for portablity for Normal HP machine;
statement for portablity for Normal HP machine;
}
#endif
staement 3;
statement 4;
}
अगर MAC_BOOK define होता है complier ,mac book के लिए code को perform करता है |नहीं तो नार्मल HP machine को code perform होता है |
Condition 3.
ये syntax condition 2 की तरह होते है जैसे
main()
{
statement 1;
statement 1;
statement 2;
#ifdef customer 1
{
statement;
}
else
{
code for customer 2;
}
#endif
staement 3;
statement 4;
}
जब customer 1 define होता है तब customer 1 से associate code perform होगा |और नहीं तो customer 2 का code perform होगा |
ANSI Addition :
ANSI addition से C language मे पहले से define preprocessor के आलावा दुसरे preprocessor को add कर सकते है |
1.#elif directive
इस preprocessor से if…else….if sequenceको बनता है |इसका उदाहरन है :-
#if expression 1
statement1
#elif expression 2
statement 2
……………..
……………..
#elif expression N
statement N
#endif
उदाहरण के लिए :
#if MACHINE==MAC
#define FILE “mac.h”
#elif MACHINE==HP
#define FILE “hp.h”
#elif MACHINE==WIPRO
#define FILE “wipro.h”
#endif
2.#pragma Directive
ये statement implementation oriented directive है जो कई प्रकार के statement कोम्प्लिएर को देता है |जैसे time और space optimization |इसका syntax है :-
#pragma name;
इसमें name ,pragma का नाम है जिसे यूजर use करना चाहता है |इसका उदाहरण है :-
#pragma loop_optimization(on);
इस statement से किसी loop को optimize करने के लिए किया जाता है |
3.#error
इस statement का use ,error message को produce करने के लिए किया जाता है |इसका syntax है :-
#error message
ये statement error message produce होता है और प्रोग्रम terminate हो जाता है |
उदाहरण के लिए :
#if !defined(FILE_G)
#error NO GRAPHIC CARD
#endif
4.Stringing operator
इस operator का use ,macro statement मे string को define करने के लिए किया जाता है |इस operator से किसी macro statement के formal argument को string मे convert कर सकते है |
जैसे
#define sub(ab) printf(#ab ” = %d \n “, ab)
main()
{
……………
……………
sub(a-b);
}
इस article मे हमने Compiler Control Directives और ANSI addition को पढ़ा |age आने वाले article मे macro based example को पढेगे |
Recent Posts
मालकाना का युद्ध malkhana ka yudh kab hua tha in hindi
malkhana ka yudh kab hua tha in hindi मालकाना का युद्ध ? मालकाना के युद्ध…
4 weeks ago
कान्हड़देव तथा अलाउद्दीन खिलजी के संबंधों पर प्रकाश डालिए
राणा रतन सिंह चित्तौड़ ( 1302 ई. - 1303 ) राजस्थान के इतिहास में गुहिलवंशी…
4 weeks ago
हम्मीर देव चौहान का इतिहास क्या है ? hammir dev chauhan history in hindi explained
hammir dev chauhan history in hindi explained हम्मीर देव चौहान का इतिहास क्या है ?…
4 weeks ago
तराइन का प्रथम युद्ध कब और किसके बीच हुआ द्वितीय युद्ध Tarain battle in hindi first and second
Tarain battle in hindi first and second तराइन का प्रथम युद्ध कब और किसके बीच…
4 weeks ago
चौहानों की उत्पत्ति कैसे हुई थी ? chahamana dynasty ki utpatti kahan se hui in hindi
chahamana dynasty ki utpatti kahan se hui in hindi चौहानों की उत्पत्ति कैसे हुई थी…
1 month ago
भारत पर पहला तुर्क आक्रमण किसने किया कब हुआ first turk invaders who attacked india in hindi
first turk invaders who attacked india in hindi भारत पर पहला तुर्क आक्रमण किसने किया…
1 month ago