When we define a variable name using #define in macro like: #define BUFFER_SIZE buff 5, and then in our main function declare a variable which has the same name like: int buff=8, Does the second buff overwrite the first one? I mean generally is a macro definition considered related to a non macro definition in main or are they totally separate?
hg_fs2002 13 Light Poster
Recommended Answers
Jump to PostYour macro is wrong
#define BUFFEFR_SIZE 5
You don't put a variable name in the macro
char buf = BUFFER_SIZE;
Jump to Postdon't use a macro to declare a variable -- just too confusing.
Does the second buff overwrite the first one
Depends on where the first one is declared. If its in the same block enclosed with { and } then there will be a compiler error for duplicate …
Jump to PostGood question.
Write a short program and output the value. Does it compile properly? If so, what does it output?
All 9 Replies
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
hg_fs2002 13 Light Poster
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
hg_fs2002 13 Light Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
hg_fs2002 13 Light Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.