What is preprocessor directive(#) and it's uses in c programming? | Sololearn: Learn to code for FREE!

0

What is preprocessor directive(#) and it's uses in c programming?

C programming

c pr

10/20/2021 2:23:42 AM

Chandan Kushwaha

4 Answers

New Answer

+3

The answer to this question is just a search away https://www.google.com/amp/s/developerinsider.co/preprocessor-directives-c-programming/amp/ #searchbeforeasking

+2

There are 3 possible answers to your question depending on what you mean. 1. A # symbol as the first character in a line denotes a preprocessor directive e.g. #include #if #ifdef #define https://docs.microsoft.com/en-us/cpp/preprocessor/preprocessor-directives?view=msvc-160 2. The # macro operator converts a macro argument into a string literal without expanding the contents. https://docs.microsoft.com/en-us/cpp/preprocessor/stringizing-operator-hash?view=msvc-160 Sometimes used to generate formatting strings. 3. The ## macro operator is the token pasting operator. https://docs.microsoft.com/en-us/cpp/preprocessor/token-pasting-operator-hash-hash?view=msvc-160 This is used heavily in the windows message cracking macros in WindowsX.h Typically examples 2 and 3 are used with code generation tools. Heavy use of these macros can make code difficult to read. To see what code results from the use of macros use the appropriate compiler command line switch... Microsoft Compiler /E https://docs.microsoft.com/en-us/cpp/build/reference/e-preprocess-to-stdout?view=msvc-160 GNU Compiler -E https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#Overall-Options

+1

As the name suggests, they are directives to contol the behaviour of preprocessor. Learn more about it here 👇 https://en.cppreference.com/w/cpp/preprocessor

-1

What is preprocessor directive(#) and it's uses in c programming? C programming