We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In syncio module, fgets is declared as:
fgets
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:
addReadLine
array[bufsize, char]
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 __.
char *__restrict __
The text was updated successfully, but these errors were encountered:
fixes nim-lang#588; Change fgets parameter type to ptr UncheckedArray…
78fed64
…[char]
NIFC should produce &buf_3.a for this.
&buf_3.a
Sorry, something went wrong.
It seems NIFC should produce buf_3.a. Following C code compiles without errors.
buf_3.a
#include <stdio.h> typedef struct { char a[80]; } Buf; Buf buf; int main() { fgets(buf.a, 80, stdin); return 0; }
Buf when I change buf.a to &buf.a, I got incompatible pointer type error.
buf.a
&buf.a
It should produce &buf.a[0], I think.
&buf.a[0]
fixes nim-lang#588; NIFC generates &buf.a[0] for arrays
37a95dd
No branches or pull requests
In syncio module,
fgets
is declared as:And
addReadLine
proc passesarray[bufsize, char]
type variable tofgets
:This code generates following C code:
This code result in compile error with GCC:
fgets
's first parameter type ischar *__restrict __
.The text was updated successfully, but these errors were encountered: