![]() |
Size of extern int x;
If i declared extern int x; in linux environment. what is the size?
|
Re: Size of extern int x;
skishorev@yahoo.co.in writes:
>If i declared extern int x; in linux environment. what is the size? Why do you suspect that it'll be anything other than sizeof(int) ? -- Chris. |
Re: Size of extern int x;
Hi,
I am asking that whether it will create memory at the time of decalaration of extern int x; |
Re: Size of extern int x;
skishorev@yahoo.co.in wrote: > I am asking that whether it will create memory at the time of > decalaration of extern int x; Quote context. Read <http://cfaj.freeshell.org/google/>. You did not make yourself clear the first time. For the `extern` declaration, no memory need be allocated, as it just tells the compiler not to worry about it, as `x` is guaranteed to exits (as a variable of type `int`) somewhere else. Exactly where this `somewhere else` is physically, will be discovered at link phase (if not, linking will fail). |
Re: Size of extern int x;
skishorev@yahoo.co.in said:
> If i declared extern int x; in linux environment. what is the size? No storage is reserved, so there isn't a size. -- Richard Heathfield "Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk email: rjh at above domain (but drop the www, obviously) |
Re: Size of extern int x;
On Tue, 16 May 2006 10:17:02 +0000, Richard Heathfield
<invalid@invalid.invalid> wrote: >skishorev@yahoo.co.in said: > >> If i declared extern int x; in linux environment. what is the size? > >No storage is reserved, so there isn't a size. One may interpret the OP's question as: "What is sizeof x?" In which case, the following code should answer that question. #include <limits.h> #include <stdio.h> extern int x; int main(void) { const int INT_BITS = (int)(sizeof(int) * CHAR_BIT); printf ( "sizeof x = %d, same as sizeof(int) = %d\n", (int)sizeof x, (int)sizeof(int) ); printf ( "type int is %d bit%s\n", INT_BITS, INT_BITS == 1 ? "" : "s" ); return 0; } int x = 0; If you can spot how a standard-compliant compiler will never achieve 100% decision coverage in the above code, then you win a prize. -- jay |
Re: Size of extern int x;
On Wed, 17 May 2006 03:03:41 -0700, jaysome <jaysome@spamcop.net>
wrote: snip code >If you can spot how a standard-compliant compiler will never achieve >100% decision coverage in the above code, then you win a prize. What does the phrase "decision coverage" mean? Remove del for email |
| All times are GMT. The time now is 04:55 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.