Home
Q&A
Education
Technology
Credit
General
Health
Insurance
Questions
Ask a Question
What is the difference between const and macro?
Home
Technology
What is the difference between const and macro?
asked
Jan 23, 2021
in
Technology
by
JackTerrance
What is the difference between const and macro?
interview-question-answer
technology-questions-answers
1
Answer
0
votes
answered
Jan 23, 2021
by
JackTerrance
The const keyword is handled by the compiler, in another hand, a macro is handled by the preprocessor directive.
const is a qualifier that is modified the behavior of the identifier but macro is preprocessor directive.
There is type checking is occurred with a const keyword but does not occur with #define.
const is scoped by C block, #define applies to a file.
const can be passed as a parameter (as a pointer) to the function. In the case of call by reference, it prevents modifying the passed object value.
Related questions
0
votes
Q: What is the difference between const and readonly in C#?
What is the difference between const and readonly in C#?...
asked
Jan 16, 2021
in
Technology
by
JackTerrance
interview-question-answer
technology-questions-answers
0
votes
Q: What is the difference between a macro and a function?
What is the difference between a macro and a function?...
asked
Jan 23, 2021
in
Technology
by
JackTerrance
interview-question-answer
technology-questions-answers
0
votes
Q: Problem creating const object in TypeScript
I'm getting the following error when trying to compile my code on Angular 7.2.0 with TypeScript version ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked
Jun 3, 2022
in
Education
by
JackTerrance
angulartypescriptobject
0
votes
Q: Problem creating const object in TypeScript
I'm getting the following error when trying to compile my code on Angular 7.2.0 with TypeScript version ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked
Jun 2, 2022
in
Education
by
JackTerrance
angulartypescriptobject
0
votes
Q: static const Color not fully working with Allegro5
I'm relatively new to C++, recently moved from C# and Java (and before that, used to work in ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked
May 7, 2022
in
Education
by
JackTerrance
c
g
0
votes
Q: Is an STL Container of const T with a custom allocator ill-formed?
Take the following code snippet: #include std::vector good; //illegal, because std::allocator is ill-formed ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked
Apr 20, 2022
in
Education
by
JackTerrance
c
14
0
votes
Q: Structured binding on const
Is the following code supposed to compile? #include void foo() { const std::pair x = {1, 2}; ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked
Apr 16, 2022
in
Education
by
JackTerrance
c
17
0
votes
Q: Structured binding on const
Is the following code supposed to compile? #include void foo() { const std::pair x = {1, 2}; ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked
Apr 16, 2022
in
Education
by
JackTerrance
c
17
0
votes
Q: Defining const values in C
I have a C project where all code is organized in *.c/*.h file pairs, and I need to define ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked
Mar 11, 2022
in
Education
by
JackTerrance
cconstantsheader-files
0
votes
Q: Defining const values in C
I have a C project where all code is organized in *.c/*.h file pairs, and I need to define ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked
Mar 10, 2022
in
Education
by
JackTerrance
cconstantsheader-files
0
votes
Q: What is the meaning of the below declarations? 1. const int a; 2. int const a; 3. const int *a; 4. int * const a; 5. int const * a const;c
What is the meaning of the below declarations? 1. const int a; 2. int const a; 3. const int *a; 4. int * const a; 5. int const * a const;c...
asked
Jan 21, 2021
by
JackTerrance
pointer-interview-questions-in-c
cprogramming
0
votes
Q: Name the predefined macro which be used to determine whether your compiler is ANSI standard or not?
Name the predefined macro which be used to determine whether your compiler is ANSI standard or not?...
asked
Nov 9, 2020
in
Technology
by
JackTerrance
interview-question-answer
technology-questions-answers
+1
vote
Q: Which operator is used to continue the definition of macro in the next line in C-Programming?
Which operator is used to continue the definition of macro in the next line in C-Programming?...
asked
Nov 9, 2020
in
Technology
by
JackTerrance
interview-question-answer
technology-questions-answers
0
votes
Q: VBA PowerPoint Online Guide and How to Record a Macro
Could anyone recommend to me a good online guide to PowerPoint VBA? Also, does anyone has advice on how ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked
Mar 16, 2022
in
Education
by
JackTerrance
vba
0
votes
Q: VBA PowerPoint Online Guide and How to Record a Macro
Could anyone recommend to me a good online guide to PowerPoint VBA? Also, does anyone has advice on how ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked
Mar 16, 2022
in
Education
by
JackTerrance
vba
...