Timeline for Is it better to use #define or const int for constants?
Current License: CC BY-SA 3.0
16 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 6, 2021 at 14:22 | answer | added | glibg10b | timeline score: 1 | |
| Mar 26, 2018 at 20:44 | history | tweeted | twitter.com/StackArduino/status/978372142302720005 | ||
| Mar 26, 2018 at 18:19 | comment | added | SDsolar |
I agree. Plus, if you look at my answer below, I demonstrate that there are circumstances when you don't really know which type to use, so #define is the obvious choice. My example is in naming Analog pins - like A5. There is no appropriate type for it that could be used as a const so the only choice is to use a #define and let the compiler substitute it as text input before interpreting the meaning.
|
|
| Mar 26, 2018 at 17:58 | answer | added | SDsolar | timeline score: 1 | |
| May 23, 2017 at 12:37 | history | edited | CommunityBot |
replaced http://stackoverflow.com/ with https://stackoverflow.com/
|
|
| Mar 7, 2014 at 16:21 | vote | accept | Cybergibbons | ||
| Mar 7, 2014 at 16:20 | vote | accept | Cybergibbons | ||
| Mar 7, 2014 at 16:21 | |||||
| S Feb 28, 2014 at 16:57 | history | suggested | Gilles 'SO- stop being evil' |
this question is specifically about c++
|
|
| Feb 28, 2014 at 16:56 | review | Suggested edits | |||
| S Feb 28, 2014 at 16:57 | |||||
| Feb 28, 2014 at 15:05 | answer | added | microtherion | timeline score: 25 | |
| S Feb 28, 2014 at 13:42 | history | suggested | The Guy with The Hat | CC BY-SA 3.0 |
improved formatting, edited tags
|
| Feb 28, 2014 at 13:40 | review | Suggested edits | |||
| S Feb 28, 2014 at 13:42 | |||||
| Feb 28, 2014 at 11:27 | comment | added | Cybergibbons | Really? I don't see how a compiler is going to resolve things like type safety, not being able to use the to define array length and so on. | |
| Feb 28, 2014 at 10:40 | answer | added | Peter Bloomfield | timeline score: 7 | |
| Feb 28, 2014 at 10:19 | comment | added | ratchet freak | a good optimizer will render it moot | |
| Feb 28, 2014 at 9:46 | history | asked | Cybergibbons | CC BY-SA 3.0 |