Skip to content
New issue

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

walkDirRec Error #2116

Closed
TheAnonymous opened this issue Feb 13, 2015 · 6 comments
Closed

walkDirRec Error #2116

TheAnonymous opened this issue Feb 13, 2015 · 6 comments

Comments

@TheAnonymous
Copy link
Contributor

I tried to make a small webapp with Jester and something strange happens when I try to use walkDirRec in a GET request like this

import os, re, jester, asyncdispatch, htmlgen, asyncnet


routes:

  get "/":
    var html = ""
    html.add "<form action=\"upload\" method=\"post\"enctype=\"multipart/form-data\">"
    html.add "<input type=\"file\" name=\"file\"value=\"file\">"
    html.add "<input type=\"submit\" value=\"Submit\" name=\"submit\">"
    html.add "</form>"
    html.add "<h3>Folder</h3>"
    for file in walkDirRec("./"):
      html.add "<li><a href=\"" &file & "\">" & file & "</li>"
    resp(html)

runForever()

i get this error

/nimcache/posix.c:103:18: error: invalid application of 'sizeof' to an incomplete type 'DIR' (aka 'struct __dirstream')
NTI103214.size = sizeof(DIR);
                 ^     ~~~~~
/usr/include/dirent.h:127:16: note: forward declaration of 'struct __dirstream'
typedef struct __dirstream DIR;
               ^
1 error generated.
Error: execution of an external program failed

I first made a ticket at the jester projekt (dom96/jester#23) but they say that this is probably a compiler bug.
This happens with "Nim Compiler Version 0.10.2 (2014-12-31) [Linux: amd64]" as also with "Nim Compiler Version 0.10.3 (2015-02-13) [Linux: amd64]"
If I don't use jester and just make a simple program like this

import os, re
for f in walkDirRec("./"):
  echo f

it works perfectly fine.

Greetings Jakob

@TheAnonymous
Copy link
Contributor Author

Hi seems like this bug needs to be reopen again but this time I get another error.
with this

import os, re, jester, asyncdispatch, htmlgen, asyncnet


routes:

  get "/":
    var html = ""
    html.add "<form action=\"upload\" method=\"post\"enctype=\"multipart/form-data\">"
    html.add "<input type=\"file\" name=\"file\"value=\"file\">"
    html.add "<input type=\"submit\" value=\"Submit\" name=\"submit\">"
    html.add "</form>"
    html.add "<h3>Folder</h3>"
    for file in walkDirRec("./"):
      html.add "<li><a href=\"" &file & "\">" & file & "</li>"
    resp(html)

runForever()

i get this error

clang -c  -w  -I/Users/jakob/Nim/lib -o /Users/jakob/Downloads/Repositorys/Uploader/nimcache/stdlib_posix.o /Users/jakob/Downloads/Repositorys/Uploader/nimcache/stdlib_posix.c
/Users/jakob/Downloads/Repositorys/Uploader/nimcache/stdlib_posix.c:134:20: error: no member named 'd_off' in 'dirent'
TMP380[3].offset = offsetof(struct dirent, d_off);
                   ^                       ~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include/stddef.h:87:24: note: 
      expanded from macro 'offsetof'
#define offsetof(t, d) __builtin_offsetof(t, d)
                       ^
1 error generated.
Error: execution of an external program failed

nim -v is
Nim Compiler Version 0.10.3 (2015-03-21) [MacOSX: amd64]
Copyright (c) 2006-2015 by Andreas Rumpf

active boot switches: -d:release

@TheAnonymous
Copy link
Contributor Author

Im sorry but even in

Nim Compiler Version 0.10.3 (2015-03-25) [MacOSX: amd64]
Copyright (c) 2006-2015 by Andreas Rumpf

I get the same error with the example code from above.

@reactormonk
Copy link
Contributor

Works for me on devel on Linux.

@TheAnonymous
Copy link
Contributor Author

Yep thats right tried it on Linux right now and it works like charm.

@TheAnonymous
Copy link
Contributor Author

Even if it works on Linux shouldn't this be reopened if it doesn't work on OSX ?

@reactormonk
Copy link
Contributor

@TheAnonymous I don't know who has an OSX machine, so fixing it yourself might be fastest.

@reactormonk reactormonk reopened this Mar 30, 2015
@Araq Araq closed this as completed in ff75cf5 Apr 3, 2015
Araq added a commit that referenced this issue Apr 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants