* constant in C @ 2004-09-24 3:36 Ankit Jain 2004-09-24 7:16 ` Andrei Bunghez 2004-09-24 7:18 ` Andrei Bunghez 0 siblings, 2 replies; 7+ messages in thread From: Ankit Jain @ 2004-09-24 3:36 UTC (permalink / raw) To: linux prg what is the size of the constant i.e #define const 123456789 thanks ankit ________________________________________________________________________ Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now http://uk.messenger.yahoo.com/download/index.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: constant in C 2004-09-24 3:36 constant in C Ankit Jain @ 2004-09-24 7:16 ` Andrei Bunghez [not found] ` <4f2e7cd304092400315c83fd1e@mail.gmail.com> 2004-09-24 7:18 ` Andrei Bunghez 1 sibling, 1 reply; 7+ messages in thread From: Andrei Bunghez @ 2004-09-24 7:16 UTC (permalink / raw) To: Ankit Jain; +Cc: linux prg Hi, Actually that 'const' has no size at all, it is not a variable, has no address. The preprocessor replaces const in the source code with 123456789, or whatever its definition is. For example: x = const + 3; will be preprocessed, and the compiler will see: x = 123456789 + 3; Therefore you cannot use sizeof(const), &const etc. Regards, Andrei On Fri, 24 Sep 2004 04:36:46 +0100 (BST), Ankit Jain <ankitjain1580@yahoo.com> wrote: > what is the size of the constant > > i.e #define const 123456789 > > thanks > > ankit > > ________________________________________________________________________ > Yahoo! Messenger - Communicate instantly..."Ping" > your friends today! Download Messenger Now > http://uk.messenger.yahoo.com/download/index.html > - > To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <4f2e7cd304092400315c83fd1e@mail.gmail.com>]
* Fwd: constant in C [not found] ` <4f2e7cd304092400315c83fd1e@mail.gmail.com> @ 2004-09-24 7:33 ` Uday Karan 2004-09-24 10:17 ` Micha Feigin 0 siblings, 1 reply; 7+ messages in thread From: Uday Karan @ 2004-09-24 7:33 UTC (permalink / raw) To: linux-c-programming Sorry didn't CC to list. > Therefore you cannot use sizeof(const), &const etc. sizeof (CONST) can be done and would return the size of an integral type that would be able to hold that value, could be 4 for ints or 8 for long ints, if none of these can take up the value (because you're substitutive constant is insanely large), the compiler would usually give out a warning (if truncating) or an error straightaway. - Uday ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Fwd: constant in C 2004-09-24 7:33 ` Fwd: " Uday Karan @ 2004-09-24 10:17 ` Micha Feigin 2004-09-24 10:47 ` Ankit Jain 0 siblings, 1 reply; 7+ messages in thread From: Micha Feigin @ 2004-09-24 10:17 UTC (permalink / raw) To: linux-c-programming On Fri, Sep 24, 2004 at 01:03:17PM +0530, Uday Karan wrote: > Sorry didn't CC to list. > > > Therefore you cannot use sizeof(const), &const etc. > > sizeof (CONST) can be done and would return the size of an integral > type that would be able to hold that value, could be 4 for ints or 8 > for long ints, if none of these can take up the value (because you're Actually the size of long int is 4 and the size of short is 2, the size of int depends on the platform. With the old 16bit platforms (if you can still find them ;-) it was 2 and with 32 bit machines its 4. Int was supposed to be a word, but on 64bit machines that is not longer stable. with 64bits, a pointer is of size 8, but int and long can be either 4 or 8 and sometimes there is long long. have look at http://en.wikipedia.org/wiki/64-bit. > substitutive constant is insanely large), the compiler would usually > give out a warning (if truncating) or an error straightaway. > > - Uday > - > To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > > +++++++++++++++++++++++++++++++++++++++++++ > This Mail Was Scanned By Mail-seCure System > at the Tel-Aviv University CC. > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Fwd: constant in C 2004-09-24 10:17 ` Micha Feigin @ 2004-09-24 10:47 ` Ankit Jain 2004-09-25 0:53 ` Micha Feigin 0 siblings, 1 reply; 7+ messages in thread From: Ankit Jain @ 2004-09-24 10:47 UTC (permalink / raw) To: Micha Feigin; +Cc: linux prg can the size be greater than 4byte on a 32 bit system? thanks ankit --- Micha Feigin <michf@post.tau.ac.il> wrote: > On Fri, Sep 24, 2004 at 01:03:17PM +0530, Uday Karan > wrote: > > Sorry didn't CC to list. > > > > > Therefore you cannot use sizeof(const), &const > etc. > > > > sizeof (CONST) can be done and would return the > size of an integral > > type that would be able to hold that value, could > be 4 for ints or 8 > > for long ints, if none of these can take up the > value (because you're > > Actually the size of long int is 4 and the size of > short is 2, the size > of int depends on the platform. With the old 16bit > platforms (if you > can still find them ;-) it was 2 and with 32 bit > machines its 4. > > Int was supposed to be a word, but on 64bit machines > that is not longer > stable. > > with 64bits, a pointer is of size 8, but int and > long can be either 4 > or 8 and sometimes there is long long. > > have look at http://en.wikipedia.org/wiki/64-bit. > > > substitutive constant is insanely large), the > compiler would usually > > give out a warning (if truncating) or an error > straightaway. > > > > - Uday > > - > > To unsubscribe from this list: send the line > "unsubscribe linux-c-programming" in > > the body of a message to majordomo@vger.kernel.org > > More majordomo info at > http://vger.kernel.org/majordomo-info.html > > > > +++++++++++++++++++++++++++++++++++++++++++ > > This Mail Was Scanned By Mail-seCure System > > at the Tel-Aviv University CC. > > > - > To unsubscribe from this list: send the line > "unsubscribe linux-c-programming" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at > http://vger.kernel.org/majordomo-info.html > ________________________________________________________________________ Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now http://uk.messenger.yahoo.com/download/index.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Fwd: constant in C 2004-09-24 10:47 ` Ankit Jain @ 2004-09-25 0:53 ` Micha Feigin 0 siblings, 0 replies; 7+ messages in thread From: Micha Feigin @ 2004-09-25 0:53 UTC (permalink / raw) To: linux prg On Fri, Sep 24, 2004 at 11:47:13AM +0100, Ankit Jain wrote: > can the size be greater than 4byte on a 32 bit system? > > thanks > I am not sure if long long support (yes, two longs) is completely standard, but on compilers where it is supported its size should be 8 bytes (64 bit). I just tested under gcc 3.3 and it is supported with it and of size 8. > ankit > --- Micha Feigin <michf@post.tau.ac.il> wrote: > > On Fri, Sep 24, 2004 at 01:03:17PM +0530, Uday Karan > > wrote: > > > Sorry didn't CC to list. > > > > > > > Therefore you cannot use sizeof(const), &const > > etc. > > > > > > sizeof (CONST) can be done and would return the > > size of an integral > > > type that would be able to hold that value, could > > be 4 for ints or 8 > > > for long ints, if none of these can take up the > > value (because you're > > > > Actually the size of long int is 4 and the size of > > short is 2, the size > > of int depends on the platform. With the old 16bit > > platforms (if you > > can still find them ;-) it was 2 and with 32 bit > > machines its 4. > > > > Int was supposed to be a word, but on 64bit machines > > that is not longer > > stable. > > > > with 64bits, a pointer is of size 8, but int and > > long can be either 4 > > or 8 and sometimes there is long long. > > > > have look at http://en.wikipedia.org/wiki/64-bit. > > > > > substitutive constant is insanely large), the > > compiler would usually > > > give out a warning (if truncating) or an error > > straightaway. > > > > > > - Uday > > > - > > > To unsubscribe from this list: send the line > > "unsubscribe linux-c-programming" in > > > the body of a message to majordomo@vger.kernel.org > > > More majordomo info at > > http://vger.kernel.org/majordomo-info.html > > > > > > +++++++++++++++++++++++++++++++++++++++++++ > > > This Mail Was Scanned By Mail-seCure System > > > at the Tel-Aviv University CC. > > > > > - > > To unsubscribe from this list: send the line > > "unsubscribe linux-c-programming" in > > the body of a message to majordomo@vger.kernel.org > > More majordomo info at > > http://vger.kernel.org/majordomo-info.html > > > > ________________________________________________________________________ > Yahoo! Messenger - Communicate instantly..."Ping" > your friends today! Download Messenger Now > http://uk.messenger.yahoo.com/download/index.html > - > To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > > +++++++++++++++++++++++++++++++++++++++++++ > This Mail Was Scanned By Mail-seCure System > at the Tel-Aviv University CC. > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: constant in C 2004-09-24 3:36 constant in C Ankit Jain 2004-09-24 7:16 ` Andrei Bunghez @ 2004-09-24 7:18 ` Andrei Bunghez 1 sibling, 0 replies; 7+ messages in thread From: Andrei Bunghez @ 2004-09-24 7:18 UTC (permalink / raw) To: Ankit Jain; +Cc: linux prg Hmm.. actually you can use sizeof(const), and it returns 4, as 123456789 is a unsigned int constant. Andrei On Fri, 24 Sep 2004 04:36:46 +0100 (BST), Ankit Jain <ankitjain1580@yahoo.com> wrote: > what is the size of the constant > > i.e #define const 123456789 > > thanks > > ankit > > ________________________________________________________________________ > Yahoo! Messenger - Communicate instantly..."Ping" > your friends today! Download Messenger Now > http://uk.messenger.yahoo.com/download/index.html > - > To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-09-25 0:53 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-24 3:36 constant in C Ankit Jain
2004-09-24 7:16 ` Andrei Bunghez
[not found] ` <4f2e7cd304092400315c83fd1e@mail.gmail.com>
2004-09-24 7:33 ` Fwd: " Uday Karan
2004-09-24 10:17 ` Micha Feigin
2004-09-24 10:47 ` Ankit Jain
2004-09-25 0:53 ` Micha Feigin
2004-09-24 7:18 ` Andrei Bunghez
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).