c++ namespace raising error in cgo

384 views
Skip to first unread message

Swaminaathan Iyer

unread,
Sep 25, 2014, 3:00:59 AM9/25/14
to golan...@googlegroups.com
--------------------s0.go file content--------
package main
/*
 #include <stdio.h>
 #include <stdlib.h>
 #include <td0.h>
*/
import "C"
import (
"fmt"
"unsafe"
)

func main() {
fmt.Println(s)
}

--------------------td0.h file content--------
namespace ns0 {
const unsigned int kDataLen = 244426;
}


-----------------------build error------------------
# command-line-arguments
In file included from s0.go:6:0:
td0.h:1:1: error: unknown type name 'namespace'
 namespace sss {
 ^
td0.h:1:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
 namespace ns0 {
               ^ 



 how to use namespace in go with cgo ?



Sebastien Binet

unread,
Sep 25, 2014, 3:05:24 AM9/25/14
to Swaminaathan Iyer, golang-nuts

Cgo is for C.
For C++, use swig.

-s

sent from my droid

--
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...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Justin Israel

unread,
Sep 25, 2014, 4:09:16 AM9/25/14
to Sebastien Binet, golang-nuts, Swaminaathan Iyer


On 25/09/2014 7:02 PM, "Sebastien Binet" <seb....@gmail.com> wrote:
>
> Cgo is for C.
> For C++, use swig.

Or a C shim w/ cgo

Reply all
Reply to author
Forward
0 new messages