473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Size of extern int x;

If i declared extern int x; in linux environment. what is the size?

May 16 '06 #1
6 3448
sk*******@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.
May 16 '06 #2
Hi,

I am asking that whether it will create memory at the time of
decalaration of extern int x;

May 16 '06 #3

sk*******@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).

May 16 '06 #4
sk*******@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)
May 16 '06 #5
On Tue, 16 May 2006 10:17:02 +0000, Richard Heathfield
<in*****@invalid.invalid> wrote:
sk*******@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
May 17 '06 #6
On Wed, 17 May 2006 03:03:41 -0700, jaysome <ja*****@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
May 21 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

35
by: wired | last post by:
Hi, I've just taught myself C++, so I haven't learnt much about style or the like from any single source, and I'm quite styleless as a result. But at the same time, I really want nice code and I...
1
by: DiskMan | last post by:
System: Redhat 7.2 Kernel-2.6.11.8 GCC-3.4.3 CCC-6.5.9 Binutils-2.15 Make-3.80 GTK/GLIB-2.6.7 For some reason my Linux box is suddenly having issues trying to read ;
14
by: Christopher Benson-Manica | last post by:
From FAQ 6.13: int arr; int (*a)=arr; /* legal, but useless */ printf( "%d\n", a ); /* error, bounds of a unspecified */ Are there non-contrived situations where an array of unspecified...
8
by: chellappa | last post by:
hi Everybody ! decalaring variable in a.h and using that vaaariable in a1.c and inalization is in main.c it is possible .........pleaase correct that error is it Possible? i am trying it...
6
by: Laurent | last post by:
Hello, This is probably a dumb question, but I just would like to understand how the C# compiler computes the size of the managed structure or classes. I'm working on this class: public...
3
by: manoj.pattanaik | last post by:
Hi, I am trying to compile following piece of code (bb.cpp) using aCC (HP ANSI C++ B3910B A.03.37) compiler on HP-UX 11.23. It gives error:485 //bb.cpp -- Starts #include <iostream> using...
9
by: joshc | last post by:
Hi, I have an array defined in one file with an intializer as follows: int arr = {0, 1, 2, 3}; I have a declaration of the array in another file as follows: extern int arr;
11
by: mast2as | last post by:
This question has been posted to this forum before and I read the thread but found that the answers were perhaps imcomplete, so I am trying again. Whenever I am creating objects I would like to...
24
by: arnuld | last post by:
I want to create a new array of the same size of an array already available: #include <stdio.h> #include <string.h> int main(void) { char arrc = "URI";
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.