Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:: [': 0.04; 'that?': 0.05; 'subject:Python': 0.06; 'compiler': 0.07; 'subject:into': 0.09; 'element.': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'subject:variable': 0.16; 'typedef': 0.16; 'value;': 0.16; 'wrote:': 0.18; 'subject:] ': 0.20; 'header:User-Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'struct': 0.31; 'quite': 0.32; 'surely': 0.36; 'subject:?': 0.36; 'message-id:@gmail.com': 0.38; 'to:addr:python- list': 0.38; 'structure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'subject:Can': 0.60; 'course': 0.61; 'first': 0.61; 'address': 0.63; 'email addr:gmail.com': 0.63 X-Virus-Scanned: amavisd-new at torriefamily.org Date: Mon, 24 Feb 2014 11:19:28 -0700 From: Michael Torrie User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131118 Thunderbird/17.0.11 MIME-Version: 1.0 To: python-list@python.org Subject: Re: [OT] Can global variable be passed into Python function? References: <27ac2248-0ca3-4ba6-9d25-eaad324bc5e9@googlegroups.com> <87sird7wuw.fsf@handshake.de> <8454E8CB-E6E3-452F-8E54-9A77BFF34EC2@gmail.com> <1m3gg9lbf2ln5m2kbki954t17mqni3b20k@4ax.com> <53095145$0$29985$c3e8da3$5496439d@news.astraweb.com> <877g8mcg1m.fsf@elektro.pacujo.net> <87ob1yay9m.fsf@elektro.pacujo.net> <08aa32de-cd51-4888-bd60-2c2b53d86ecc@googlegroups.com> In-Reply-To: <08aa32de-cd51-4888-bd60-2c2b53d86ecc@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393265975 news.xs4all.nl 2890 [2001:888:2000:d::a6]:36773 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66988 On 02/24/2014 11:05 AM, j.e.haque@gmail.com wrote: > typedef struct { > int value; > } Number; > > Number *o; > o = malloc(sizeof(*o)); > o->value=3; > printf("o<%p>, o->value<%p>\n", o, &o->value); > > o<0x9fe5008>, o->value<0x9fe5008> > > Is the compiler borked? Why would you think that? The address of the start of your malloc'ed structure is the same as the address of the first element. Surely this is logical? And of course all this is quite off topic.