Re: [go-nuts] How to access pointer to pointer in cgo

2017-07-05 Thread Manohar Reddy


okay the golang’s alternative for `optional->_32->Magic` is simply 
`optional._32.Magic.`


So I’ve written my code regarding the about statement is given in 
https://play.golang.org/p/8sIAlxsmcj


Thanks, solved.


On Wednesday, July 5, 2017 at 7:02:10 PM UTC+5:30, Nathan Kerr wrote:
>
> Did you assign something to the pointer?
>
> My guess is that you did not, because the code compiles and then fails at 
> runtime telling the pointer is NULL.
>
> On Wednesday, July 5, 2017 at 1:19:47 PM UTC+2, Manohar Reddy wrote:
>>
>> > fmt.Println(optional._32.Magic) // did not work for me: HOW TO ACCESS 
>> MAGIC VARIABLE
>>
>> This line returns null pointer de-reference at run time. 
>> Can you please guide me on how what is the  alternative for optional->_32
>> ->Magic in Golang?
>>
>> Thanks
>> On Wednesday, July 5, 2017 at 4:42:07 PM UTC+5:30, Jan Mercl wrote:
>>>
>>> On Wed, Jul 5, 2017 at 1:04 PM Manohar Reddy  wrote:
>>>
>>> > fmt.Println(optional._32.Magic) // did not work for me: HOW TO ACCESS 
>>> MAGIC VARIABLE
>>>
>>> Who wants to guess what does "did not work for me" mean without having 
>>> the source code and the compiler output to look at?
>>>
>>> Please post a complete example at eg. the Go playgound: 
>>> https://play.golang.org/
>>>
>>> -- 
>>>
>>> -j
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] How to access pointer to pointer in cgo

2017-07-05 Thread Nathan Kerr
Did you assign something to the pointer?

My guess is that you did not, because the code compiles and then fails at 
runtime telling the pointer is NULL.

On Wednesday, July 5, 2017 at 1:19:47 PM UTC+2, Manohar Reddy wrote:
>
> > fmt.Println(optional._32.Magic) // did not work for me: HOW TO ACCESS 
> MAGIC VARIABLE
>
> This line returns null pointer de-reference at run time. 
> Can you please guide me on how what is the  alternative for optional->_32
> ->Magic in Golang?
>
> Thanks
> On Wednesday, July 5, 2017 at 4:42:07 PM UTC+5:30, Jan Mercl wrote:
>>
>> On Wed, Jul 5, 2017 at 1:04 PM Manohar Reddy  wrote:
>>
>> > fmt.Println(optional._32.Magic) // did not work for me: HOW TO ACCESS 
>> MAGIC VARIABLE
>>
>> Who wants to guess what does "did not work for me" mean without having 
>> the source code and the compiler output to look at?
>>
>> Please post a complete example at eg. the Go playgound: 
>> https://play.golang.org/
>>
>> -- 
>>
>> -j
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] How to access pointer to pointer in cgo

2017-07-05 Thread Manohar Reddy
> fmt.Println(optional._32.Magic) // did not work for me: HOW TO ACCESS 
MAGIC VARIABLE

This line returns null pointer de-reference at run time. 
Can you please guide me on how what is the  alternative for optional->_32->
Magic in Golang?

Thanks
On Wednesday, July 5, 2017 at 4:42:07 PM UTC+5:30, Jan Mercl wrote:
>
> On Wed, Jul 5, 2017 at 1:04 PM Manohar Reddy  > wrote:
>
> > fmt.Println(optional._32.Magic) // did not work for me: HOW TO ACCESS 
> MAGIC VARIABLE
>
> Who wants to guess what does "did not work for me" mean without having the 
> source code and the compiler output to look at?
>
> Please post a complete example at eg. the Go playgound: 
> https://play.golang.org/
>
> -- 
>
> -j
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] How to access pointer to pointer in cgo

2017-07-05 Thread Jan Mercl
On Wed, Jul 5, 2017 at 1:04 PM Manohar Reddy  wrote:

> fmt.Println(optional._32.Magic) // did not work for me: HOW TO ACCESS
MAGIC VARIABLE

Who wants to guess what does "did not work for me" mean without having the
source code and the compiler output to look at?

Please post a complete example at eg. the Go playgound:
https://play.golang.org/

-- 

-j

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] How to access pointer to pointer in cgo

2017-07-05 Thread Manohar Reddy



These are the things I have in C.


IMAGE_OPTIONAL_HEADER *pe_optional(pe_ctx_t *ctx);

typedef struct {
  uint16_t Magic;
}IMAGE_OPTIONAL_HEADER_32;

typedef struct {
  uint16_t type;
  IMAGE_OPTIONAL_HEADER_32 *_32;
}IMAGE_OPTIONAL_HEADER;




In c language to access Magic variable, I did  this and it worked. 


IMAGE_OPTIONAL_HEADER *optional = pe_optional();
printf(“%d \n”, optional->_32->Magic)


But how to access the same in golnag? I did


optional := pe_optional();
fmt.Println(optional._type) // worked for me 
fmt.Println(optional._32.Magic) // did not work for me: HOW TO ACCESS MAGIC 
VARIABLE



Doubt is : how to do I access `Magic` variable in go?


Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.