हिंदी माध्यम नोट्स
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
सती रासो किसकी रचना है , sati raso ke rachnakar kaun hai in hindi , सती रासो के लेखक कौन है
सती रासो के लेखक कौन है सती रासो किसकी रचना है , sati raso ke…
1 day ago
मारवाड़ रा परगना री विगत किसकी रचना है , marwar ra pargana ri vigat ke lekhak kaun the
marwar ra pargana ri vigat ke lekhak kaun the मारवाड़ रा परगना री विगत किसकी…
1 day ago
राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए sources of rajasthan history in hindi
sources of rajasthan history in hindi राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए…
3 days ago
गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है ? gurjaratra pradesh in rajasthan in hindi
gurjaratra pradesh in rajasthan in hindi गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है…
3 days ago
Weston Standard Cell in hindi वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन
वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन Weston Standard Cell in…
3 months ago
polity notes pdf in hindi for upsc prelims and mains exam , SSC , RAS political science hindi medium handwritten
get all types and chapters polity notes pdf in hindi for upsc , SSC ,…
3 months ago