linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: viresh kumar <viresh.linux@gmail.com>
To: linux-c-programming@vger.kernel.org
Cc: Shiraz HASHIM <shiraz.hashim@st.com>,
	"pratyush.anand" <pratyush.anand@st.com>,
	"vipin.kumar" <vipin.kumar@st.com>,
	Viresh KUMAR <viresh.kumar@st.com>,
	Vipul Kumar SAMAR <vipulkumar.samar@st.com>,
	bhavna.yadav@st.com, Deepak SIKRI <deepak.sikri@st.com>,
	Armando VISCONTI <armando.visconti@st.com>,
	Bhupesh SHARMA <bhupesh.sharma@st.com>,
	rajeev <rajeev-dlh.kumar@st.com>, Amit VIRDI <Amit.VIRDI@st.com>
Subject: Query: Declaring arrays as extern
Date: Thu, 22 Dec 2011 14:34:05 +0530	[thread overview]
Message-ID: <CAOh2x=ktZBLD2KDOxdBGtz0Acqc0RDkA-VrCCCO2Nby8D=2FRg@mail.gmail.com> (raw)

Hi,

I can observing an behavior which i am not able to explain.

file1.c

/* global array */
int arr[10];

void main()
{
    printf("addres of array is %p", arr);
}


file2.c
extern int arr[];

void main()
{
    printf("addres of array is %p", arr);
}


file3.c
extern int *arr;


void main()
{
    printf("addres of array is %p", arr);
}




Now, value printed with file 1 and 2 are same, but extern int *arr
doesn't work at all. The address shown is just something else.

I know we pass array addresses to routines this way only, but with
extern it is just not working.

Can somebody please explain it?

--
viresh

             reply	other threads:[~2011-12-22  9:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-22  9:04 viresh kumar [this message]
2011-12-22  9:04 ` Query: Declaring arrays as extern viresh kumar
2011-12-23 16:38   ` subin gangadharan
2011-12-23 18:27 ` Alok Singhal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOh2x=ktZBLD2KDOxdBGtz0Acqc0RDkA-VrCCCO2Nby8D=2FRg@mail.gmail.com' \
    --to=viresh.linux@gmail.com \
    --cc=Amit.VIRDI@st.com \
    --cc=armando.visconti@st.com \
    --cc=bhavna.yadav@st.com \
    --cc=bhupesh.sharma@st.com \
    --cc=deepak.sikri@st.com \
    --cc=linux-c-programming@vger.kernel.org \
    --cc=pratyush.anand@st.com \
    --cc=rajeev-dlh.kumar@st.com \
    --cc=shiraz.hashim@st.com \
    --cc=vipin.kumar@st.com \
    --cc=vipulkumar.samar@st.com \
    --cc=viresh.kumar@st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).