590 views
0 votes
0 votes
How far is Defining a function and macro related with each other?

2 Answers

1 votes
1 votes
macros are processed before the program is compiled and function are not processed but compiled.
0 votes
0 votes
  • Macro is a preprocessor directive. Means macro is called before compilation started by a compiler . Macros are of two types 
  1. Object like Macro-   #define NUMBERS
  2. Funtion like Macro- Inline function i.e. #define foo()
  • In the other side function can be created at the time Macro function call(as described before) and also can create without Macro function call.

Without Macro function call means it can create in compilation phase, and can create parse tree in the Lexical Analysis Phase i.e. 1st phase of a compiler

https://gateoverflow.in/166357/doubt

https://web.eecs.umich.edu/~prabal/teaching/eecs373-f11/readings/Preprocessor.pdf

https://www.slac.stanford.edu/comp/unix/gnu-info/cpp_1.html

https://www.slac.stanford.edu/comp/unix/gnu-info/m4_1.html

https://see.stanford.edu/Course/CS107/206

I think now how macro works will be clear

edited by

Related questions

1 votes
1 votes
1 answer
1
jugnu1337 asked May 10, 2022
282 views
SOURCE NAME::: UNDERSTANDING POINTER IN C (BOOK) BY YASHWANT KANETKARmy answer is C am i right?
1 votes
1 votes
0 answers
2
aakash pandey asked Apr 30, 2022
289 views
We use character array to declare string in C. So, if I declare an array likecharacter ch[ ] = {‘a’,’k’,’a’,’/o’};and try printing ch[3] like :printf(“%...
0 votes
0 votes
0 answers
3
Anirudh Kaushal asked Apr 6, 2022
198 views
#include<stdio.h struct marks { int p:3; int c:3; int m:2; }; void main() { struct marks s = {2, -6, 5}; printf("%d %d %d", s.p, s.c, s.m); }What does p:3 means here ?
0 votes
0 votes
0 answers
4