Skip to content

addReadLine proc in syncio module causes incompatible pointer type error from GCC #588

Closed
@demotomohiro

Description

@demotomohiro

In syncio module, fgets is declared as:

proc fgets(str: out array[bufsize, char]; n: int32; f: File): cstring {.
  importc: "fgets", header: "<stdio.h>".}

And addReadLine proc passes array[bufsize, char] type variable to fgets:

  var buf: array[bufsize, char]
  while fgets(buf, bufsize.int32, f) != nil:

This code generates following C code:

  AarrayAcS8ZS80_0_t buf_3;
  while ((!(((void*)fgets((&buf_3), ((NI32)bufsize_0_syn1lfpjv), f_22)) == NIM_NIL))){

This code result in compile error with GCC:

nifcache/syn1lfpjv.c:446:28: error: passing argument 1 of ‘fgets’ from incompatible pointer type [-Wincompatible-pointer-types]
  446 |   while ((!(((void*)fgets((&buf_3), ((NI32)bufsize_0_syn1lfpjv), f_22)) == NIM_NIL))){
      |                           ~^~~~~~~
      |                            |
      |                            AarrayAcS8ZS80_0_t *

fgets's first parameter type is char *__restrict __.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions