could not determine kind of name for C.uint32_t

1,583 views
Skip to first unread message

Ignazio Di Napoli

unread,
Mar 24, 2017, 11:54:18 AM3/24/17
to golang-nuts
Hello everyone,

I get this error while compiling gosndfile under Ubuntu. The same code compiled fine under Windows using MSYS2.
I couldn't find any information on this problem, if not checking for blank lines before <<import "C">>, that obviously are not there since it works under MSYS2. 
I also checked line endings and they're fine.
How can debug the problem?


Thank you
Ignazio

Jan Mercl

unread,
Mar 24, 2017, 12:03:19 PM3/24/17
to Ignazio Di Napoli, golang-nuts
On Fri, Mar 24, 2017 at 4:54 PM Ignazio Di Napoli <necl...@gmail.com> wrote:

> How can debug the problem?

Assuming the error comes from[0], I would try to add <stdint.h> to the list of C includes near the top of that file.

--

-j

Ignazio Di Napoli

unread,
Mar 24, 2017, 12:34:38 PM3/24/17
to golang-nuts
Thank you. Now it complains it cannot convert uint32_t to uint. It's a start. It just seems strange I can compile under Windows with MinGW 64bit and not Ubuntu 64bit.

Ignazio Di Napoli

unread,
Mar 24, 2017, 4:55:47 PM3/24/17
to golang-nuts
When I include stdints.h, the error is:

    cannot use C.uint32_t(bi.Time_reference_low) (type C.uint32_t) as type C.uint in assignment

on line:

    c.time_reference_low = C.uint32_t(bi.Time_reference_low)

Even if in stdint.h there is:

   typedef unsigned int uint32_t;

and the c is of type:

    #define SF_BROADCAST_INFO_VAR(coding_hist_size) \
struct \
{ char description [256] ; \
char originator [32] ; \
char originator_reference [32] ; \
char origination_date [10] ; \
char origination_time [8] ; \
unsigned int time_reference_low ; \
unsigned int time_reference_high ; \
short version ; \
char umid [64] ; \
char reserved [190] ; \
unsigned int coding_history_size ; \
char coding_history [coding_hist_size] ; \
}

I use gcc 6.2.0. 

Any idea?

Thank you.

Justin Israel

unread,
Mar 24, 2017, 11:09:25 PM3/24/17
to Ignazio Di Napoli, golang-nuts


On Sat, Mar 25, 2017, 9:55 AM Ignazio Di Napoli <necl...@gmail.com> wrote:
When I include stdints.h, the error is:

    cannot use C.uint32_t(bi.Time_reference_low) (type C.uint32_t) as type C.uint in assignment

If cgo follows the same rule as the Go spec, then it won't want to do implicit conversations between types. Have you tried being explicit by wrapping it in C.uint() ? 


on line:

    c.time_reference_low = C.uint32_t(bi.Time_reference_low)

Even if in stdint.h there is:

   typedef unsigned int uint32_t;

and the c is of type:

    #define SF_BROADCAST_INFO_VAR(coding_hist_size) \
struct \
{ char description [256] ; \
char originator [32] ; \
char originator_reference [32] ; \
char origination_date [10] ; \
char origination_time [8] ; \
unsigned int time_reference_low ; \
unsigned int time_reference_high ; \
short version ; \
char umid [64] ; \
char reserved [190] ; \
unsigned int coding_history_size ; \
char coding_history [coding_hist_size] ; \
}

I use gcc 6.2.0. 

Any idea?

Thank you.

--
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.

Ignazio Di Napoli

unread,
Mar 25, 2017, 1:17:47 AM3/25/17
to golang-nuts
Thank you! I found out: Ubuntu and MSYS2 ship two different versions that have different types in header according Go rules. That's why I cannot use the same code.
Reply all
Reply to author
Forward
0 new messages