On Tue, Aug 7, 2018 at 2:42 PM 陈一剑 <[email protected]> wrote:
> I want to print 333,but the result is strange.
The answer is provided by the compiler itself:
jnml@r550:~/src/tmp> cat main.go
package main
import (
"fmt"
/*
struct Test{
int ID;
};
struct Test * test(){
struct Test test;
test.ID=333;
return &test;
};
*/
"C"
)
func main() {
b := C.test()
fmt.Println(b.ID)
}
jnml@r550:~/src/tmp> go run main.go
# command-line-arguments
./main.go: In function ‘test’:
./main.go:14:6: warning: function returns address of local variable
[-Wreturn-local-addr]
return &test;
^
1
jnml@r550:~/src/tmp>
--
-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 [email protected].
For more options, visit https://groups.google.com/d/optout.