Groups
Groups
Sign in
Groups
Groups
golang-nuts
Conversations
About
Send feedback
Help
dont understand cgo. printf doesnt print a thing?
163 views
Skip to first unread message
sperber...@googlemail.com
unread,
Jan 25, 2015, 3:54:41 AM
1/25/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golan...@googlegroups.com
Hi folks,
i have the following code:
package main
/*
#include <stdio.h>
#include <stdlib.h>
int myinit(int x) {
printf("%s hello","test");
return x;
}
*/
import "C"
import "fmt"
func main() {
x := C.myinit(3)
fmt.Println(x)
}
if i do a go build and run it the output is the following:
$ ./main
3
why is nothing printed? can someone explain what i am doing wrong?
It doesnt matter if i use go1.4 or go1.5+devel
yours
Dmitry Vyukov
unread,
Jan 25, 2015, 10:45:38 PM
1/25/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sperber...@googlemail.com, golang-nuts
Try to add \n at the end of the string, or call fflush(stdout);
Reply all
Reply to author
Forward
0 new messages