Re: [OT] Can global variable be passed into Python function?

2014-03-03 Thread Grant Edwards
On 2014-03-02, Chris Angelico ros...@gmail.com wrote: On Mon, Mar 3, 2014 at 3:55 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: On 02/03/2014 16:45, Grant Edwards wrote: That's irrelevent. The actual location of the memory containing the struct object (static, stack, heap, shared)

Re: [OT] Can global variable be passed into Python function?

2014-03-03 Thread Chris Angelico
On Tue, Mar 4, 2014 at 1:18 AM, Grant Edwards invalid@invalid.invalid wrote: Note that, technically, Grant is correct as long as you grant (heh) that a structure may have an invisible member, the virtual function table pointer. C++ only (I don't believe C has virtual functions - but it may

Re: [OT] Can global variable be passed into Python function?

2014-03-02 Thread Dave Angel
Chris Angelico ros...@gmail.com Wrote in message: On Sun, Mar 2, 2014 at 3:02 PM, Dave Angel da...@davea.name wrote: The quote you make from the C standard doesn't mention malloc, so you're arguing different things. It's not the compiler that casts the malloc return value to the struct

Re: [OT] Can global variable be passed into Python function?

2014-03-02 Thread Chris Angelico
On Mon, Mar 3, 2014 at 12:22 AM, Dave Angel da...@davea.name wrote: Sure, for some definition of usable. Overhead such as block size, freelist pointer etc., are obviously outside of the returned block. But the array size that's specified in a call to new [], and the vptr, are definitely

Re: [OT] Can global variable be passed into Python function?

2014-03-02 Thread Grant Edwards
On 2014-03-02, Dave Angel da...@davea.name wrote: Grant Edwards invalid@invalid.invalid Wrote in message: On 2014-02-24, Michael Torrie torr...@gmail.com wrote: 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.

Re: [OT] Can global variable be passed into Python function?

2014-03-02 Thread Mark Lawrence
On 02/03/2014 16:45, Grant Edwards wrote: That's irrelevent. The actual location of the memory containing the struct object (static, stack, heap, shared) doesn't matter. The address of the first field in a struture object _is_ the address of the structure object. You say struture, I'll say

Re: [OT] Can global variable be passed into Python function?

2014-03-02 Thread Dave Angel
Chris Angelico ros...@gmail.com Wrote in message: On Mon, Mar 3, 2014 at 12:22 AM, Dave Angel da...@davea.name wrote: Sure, for some definition of usable. Overhead such as block size, freelist pointer etc., are obviously outside of the returned block. But the array size that's specified

Re: [OT] Can global variable be passed into Python function?

2014-03-02 Thread Chris Angelico
On Mon, Mar 3, 2014 at 3:55 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: On 02/03/2014 16:45, Grant Edwards wrote: That's irrelevent. The actual location of the memory containing the struct object (static, stack, heap, shared) doesn't matter. The address of the first field in a

Re: [OT] Can global variable be passed into Python function?

2014-03-02 Thread Chris Angelico
On Mon, Mar 3, 2014 at 6:17 AM, Dave Angel da...@davea.name wrote: Array size is inside the malloc block, but outside the struct block. As you can see if you try to delete without the brackets when you used new [], some runtimes will crash. As in, you have to use delete [] x to correspond

Re: [OT] Can global variable be passed into Python function?

2014-03-02 Thread Dave Angel
Chris Angelico ros...@gmail.com Wrote in message: } so in that case, the array size is inside the malloc'd block, but it's still invisible to the calling function. Please quit using negative language when you're so vehemently agreeing with me. The data is sometimes not at the

Re: [OT] Can global variable be passed into Python function?

2014-03-01 Thread Grant Edwards
On 2014-02-24, Michael Torrie torr...@gmail.com wrote: On 02/24/2014 11:05 AM, j.e.ha...@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); o0x9fe5008, o-value0x9fe5008 Is the compiler

Re: [OT] Can global variable be passed into Python function?

2014-03-01 Thread Dave Angel
Grant Edwards invalid@invalid.invalid Wrote in message: On 2014-02-24, Michael Torrie torr...@gmail.com wrote: 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? Not only is it logical,

Re: [OT] Can global variable be passed into Python function?

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 3:02 PM, Dave Angel da...@davea.name wrote: The quote you make from the C standard doesn't mention malloc, so you're arguing different things. It's not the compiler that casts the malloc return value to the struct type. C++ does implicitly convert the result, and

Re: [OT] Can global variable be passed into Python function?

2014-02-24 Thread Michael Torrie
On 02/24/2014 11:05 AM, j.e.ha...@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); o0x9fe5008, o-value0x9fe5008 Is the compiler borked? Why would you think that? The address of the

Re: [OT] Can global variable be passed into Python function?

2014-02-24 Thread random832
On Mon, Feb 24, 2014, at 13:19, Michael Torrie wrote: 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. That's not helpful - the problem, in