On Mon, 2003-08-18 at 20:13, Erik Price wrote:
However, what is the convention in C? There seem to be two fine ways
of doing it -- using the preprocessor, or the const keyword:
#define NUMBER_OF_UNITS 8
const int NUMBER_OF_UNITS = 8;
Generally, the more the compiler knows, the better it
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On Mon, 18 Aug 2003 20:53:01 -0400
Ray Cote [EMAIL PROTECTED] wrote:
At 8:13 PM -0400 8/18/03, Erik Price wrote:
However, what is the convention in C? There seem to be two fine
ways of doing it -- using the preprocessor, or the const keyword:
Derek Martin [EMAIL PROTECTED] writes:
On Mon, Aug 18, 2003 at 08:13:05PM -0400, Erik Price wrote:
However, what is the convention in C? There seem to be two fine
ways of doing it -- using the preprocessor, or the const keyword:
#define NUMBER_OF_UNITS 8
const int NUMBER_OF_UNITS
On Tue, Aug 19, 2003 at 02:50:01AM -0400, Aaron Hope [EMAIL PROTECTED] wrote:
On Mon, 2003-08-18 at 20:13, Erik Price wrote:
However, what is the convention in C? There seem to be two fine ways
of doing it -- using the preprocessor, or the const keyword:
#define NUMBER_OF_UNITS 8
const
Aaron Hope [EMAIL PROTECTED] writes:
On Mon, 2003-08-18 at 20:13, Erik Price wrote:
However, what is the convention in C? There seem to be two fine ways
of doing it -- using the preprocessor, or the const keyword:
#define NUMBER_OF_UNITS 8
const int NUMBER_OF_UNITS = 8;
On Tue, Aug 19, 2003 at 09:07:23AM -0400, Kevin D. Clark [EMAIL PROTECTED] wrote:
Another possibility is to use enums, i.e.:
enum { BUFSIZE=512 };
char arr[BUFSIZE];
I use this frequently, and I recommend this.
One advantage of enum's is that symbolic debuggers can display
On Tue, 2003-08-19 at 09:53, [EMAIL PROTECTED] wrote:
To avoid rehashing, here are the two arguments:
Reply-To Munging Considered Harmful
http://www.unicom.com/pw/reply-to-harmful.html
Reply-To Munging Considered Useful
http://www.metasystema.org/essays/reply-to-useful.mhtml
Thank God
However, what is the convention in C? There seem to be two fine ways
of doing it -- using the preprocessor, or the const keyword:
#define NUMBER_OF_UNITS 8
const int NUMBER_OF_UNITS = 8;
I'm just interested in hearing about whether one is more appropriate
than the other in some
On Tue, Aug 19, 2003 at 02:50:01AM -0400, Aaron Hope wrote:
BTW, Is there a reason why mailman isn't configured to set the
reply-to header?
Yes. We've had this holy war before, and the (small) majority of list
members were against reply-to. The logical argument:
Setting the reply-to header
On Tue, 19 Aug 2003, at 2:50am, [EMAIL PROTECTED] wrote:
BTW, Is there a reason why mailman isn't configured to set the reply-to
header?
Some time back, the list took a vote, and more people voted harmful then
useful, and we went with the plurality.
To avoid rehashing, here are the two
Tom Fogal wrote:
I'm just interested in hearing about whether one is more appropriate
than the other in some contexts. Thanks.
Generally, I would use #defines for anything but function parameters.
Passing things as a constant reference (const type val) is a good way to
avoid passing a large
Tom Fogal [EMAIL PROTECTED] writes:
the const int way stores the variable in read only memory, and thus, IMO is a
waste of memory. Also, it would be required to do a memory lookup when
accessing the value.
The value *might* get stored in read-only memory. The standard
doesn't require this.
Tom Fogal wrote:
I'm just interested in hearing about whether one is more appropriate
than the other in some contexts. Thanks.
Generally, I would use #defines for anything but function parameters.
Passing things as a constant reference (const type val) is a good way to
avoid
Tom Fogal wrote:
The bit about memory addresses instead of some large value is entirely correct.
Practically however, this will only be better when passing a value larger than
the register size of the architecture you are on. For instance, on ix86 linux,
all pointers are 32-bit integers. Thus
Tom Fogal [EMAIL PROTECTED] writes:
The const is purely optional; you could just as easily remember yourself that
'hey, i dont want to change that value in this function' and simply not do it.
The justification i was given for such usage is that someone who is not you
can quickly look at the
ANSI C allows the implementation to store duplicate strings in the
same memory location at runtime.
I stand corrected. My claim came from a very old document. The only
(draft) version of the ISO standard I have at my finger tips says it is
now unspecified. I think my argument still stands
On Tue, 2003-08-19 at 08:46, Bob Bell wrote:
Actually, the following is valid C99:
const int m = 10;
int
foo(int n) {
char s[n];
char t[m];
...
}
Yes, C99 supports variable sized arrays, but that's not always what you
When I want to define a constant value in Java, such as a magic number,
I usually use public static final:
public static final int NUMBER_OF_UNITS = 8;
However, what is the convention in C? There seem to be two fine ways
of doing it -- using the preprocessor, or the const keyword:
On Mon, Aug 18, 2003 at 08:13:05PM -0400, Erik Price wrote:
However, what is the convention in C? There seem to be two fine
ways of doing it -- using the preprocessor, or the const keyword:
#define NUMBER_OF_UNITS 8
const int NUMBER_OF_UNITS = 8;
Normally, the former way is what you'd
At 8:13 PM -0400 8/18/03, Erik Price wrote:
However, what is the convention in C? There seem to be two fine
ways of doing it -- using the preprocessor, or the const keyword:
#define NUMBER_OF_UNITS 8
const int NUMBER_OF_UNITS = 8;
This tends to be the nicer way to do it these days.
Biggest
On Mon, Aug 18, 2003 at 08:52:16PM -0400, Derek Martin wrote:
beyond what is required to store the opcode and its operands. Whereas
the second method allocates storage in the segment of memory
associated with initialized data that hangs around, so that it can
contain the constant.
Er,
21 matches
Mail list logo