Linked Questions

74 votes
6 answers
136k views

Possible Duplicates: Why would someone use #define to define constants? difference between a macro and a const in c++ C++ - enum vs. const vs. #define What is the difference between using #...
afaolek's user avatar
  • 8,891
-1 votes
1 answer
3k views

Which is better: #define PI 3.14 or const double PI = 3.14; This was an interview question, and I don't seem to find an unambiguous answer. I suppose I should prefer not to use macros, but I'd like ...
Ferenc Dajka's user avatar
  • 1,051
1 vote
1 answer
297 views

I would like to understand the difference between defining a constant variable as follows: const int ONE = 1; and using a preprocessor directive: #define ONE (1) I know that in the second case "1" ...
undy's user avatar
  • 93
158 votes
16 answers
169k views

I'm looking for a way to reliably determine whether C++ code is being compiled in 32 vs 64 bit. We've come up with what we think is a reasonable solution using macros, but was curious to know if ...
Joe Corkery's user avatar
  • 2,634
49 votes
10 answers
8k views

In C, shall I prefer constants over defines? I've reading a lot of code lately, and all of the examples make heavy use of defines.
helpermethod's user avatar
  • 62.8k
18 votes
5 answers
1k views

I know the basic rules, use inline, enum and const instead of #define, that is not what I'm after with this question. What I want to know is what is considered an acceptable scenario in which you ...
gorba's user avatar
  • 388
7 votes
6 answers
12k views

#define dItemName L"CellPhone"
Christopher Peterson's user avatar
3 votes
3 answers
26k views

#define MAXSTR "Maximum number reached" char *str = MAXSTR; While doing this kind of operation. Code is working & running fine but I am getting lint error. How I can resolve it? Error: ...
kapilddit's user avatar
  • 1,809
4 votes
3 answers
10k views

What are the advantages and disadvantages of using #define over const (and vice versa)? When I read about bad programming practices specifically magic numbers, I found myself using #define more ...
DarkPotatoKing's user avatar
1 vote
2 answers
597 views

What's the best practice for the use of some static info like: Server base url Some path file ... I think that we can found some different solutions for this: It's possible to add these informations ...
Safari's user avatar
  • 12k
0 votes
4 answers
484 views

I don't see the need of using macro to define something , say in below example: #define TELEPHONE 443 //why use this int telephone = 443; //when same job is done by a regular variable why would any ...
David Prun's user avatar
  • 8,473
0 votes
0 answers
122 views

I'm writing a program that need to using two mutex and 30+25 threads to run. However it made a segmentation fault. It successful complie, but fail to run. The segmentation fault is start in the ...
Tom fong's user avatar