On Mon, Jan 15, 2018 at 11:54 AM,  <tonywalker...@gmail.com> wrote:
>
> Thanks Ian. This did the trick and now I'm faced with the problem of
> function signatures that include 'const'. On my system, fopen is declared
> thus:
> extern FILE *fopen (char *p0, char *modes) __wur
> But fopen64 is:
> extern FILE *fopen64 (const char *__restrict __filename, const char
> *__restrict __modes) __wur
>
> So, now my override function conflicts:
>
> In file included from _cgo_export.c:3:0:
> cgo-gcc-export-header-prolog:44:14: error: conflicting types for ‘fopen64’
> In file included from ./main.go:5:0,
>                  from _cgo_export.c:3:
> /usr/include/stdio.h:298:14: note: previous declaration of ‘fopen64’ was
> here
>  extern FILE *fopen64 (const char *__restrict __filename,
>               ^~~~~~~
> _cgo_export.c:37:7: error: conflicting types for ‘fopen64’
>  FILE* fopen64(char* p0, char* p1)
>        ^~~~~~~
>
> I'm guessing there's not much I can do about the limitation of dealing with
> 'const' declarations in C?

The simplist workaround is to export go_fopen64, and write a tiny
fopen64 in a different C file, with the right signature, that calls
go_fopen64.

Ian



> On Monday, January 15, 2018 at 2:35:19 PM UTC-5, Ian Lance Taylor wrote:
>>
>> You neglected to say which system you are running on.  If it's
>> GNU/Linux, note that fopen64 is not declared by default.  It's only
>> declared if define the C preprocessor macro _LARGEFILE64_SOURCE while
>> compiling the file.  You may need a #cgo CFLAGS: line to add a -D
>> option.
>>
>> Ian
>
> --
> 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.

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

Reply via email to