ctypeslib icon indicating copy to clipboard operation
ctypeslib copied to clipboard

clang2py option issues

Open sstjohn opened this issue 9 years ago • 1 comments

  • --clang-args CLANG_ARGS clang options

    • The argument to this long option actually needs to be set with an equals:
    $ clang2py --clang-args -std=c99 test.h > /dev/null || echo failed
    usage: clang2py [-h] [-c] [-d] [--debug] [-e] [-k TYPEKIND] [-i] [-l DLLS]
                    [-m module] [-o OUTPUT] [-p DLL] [-q] [-r EXPRESSION]
                    [-s SYMBOL] [-t TARGET] [-v] [-V] [-w W] [-x]
                    [--show-ids SHOWIDS] [--max-depth N] [--clang-args CLANG_ARGS]
                    files [files ...]
    clang2py: error: argument --clang-args: expected one argument
    failed
    $ clang2py --clang-args=-std=c99 test.h > /dev/null && echo success
    success
    
    • Multiple clang options also need to be quoted:
    $ clang2py --clang-args=-std=c99 -Wall test.h > /dev/null || echo failed
    usage: clang2py [-h] [-c] [-d] [--debug] [-e] [-k TYPEKIND] [-i] [-l DLLS]
                    [-m module] [-o OUTPUT] [-p DLL] [-q] [-r EXPRESSION]
                    [-s SYMBOL] [-t TARGET] [-v] [-V] [-w W] [-x]
                    [--show-ids SHOWIDS] [--max-depth N] [--clang-args CLANG_ARGS]
                    files [files ...]
    clang2py: error: unrecognized arguments: -Wall
    failed
    $ clang2py --clang-args="-std=c99 -Wall" test.h > /dev/null && echo success
    success
    
  • -l DLLS, --include-librarie DLLS libraries to search for exported functions

    • Singular of 'libraries' is 'library', with a Y.
    • This option doesn't actually appear to support multiple DLL arguments, just one:
    $ clang2py --include-librarie /lib/x86_64-linux-gnu/libc.so.6 test.h >/dev/null && echo success
    success
    $ clang2py --include-librarie /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libm.so.6 test.h > /dev/null || echo failed
    Traceback (most recent call last):
      File "/usr/local/bin/clang2py", line 6, in <module>
        sys.exit(main())
      File "/usr/local/lib/python2.7/dist-packages/ctypeslib/clang2py.py", line 310, in main 
        flags=clang_opts)
      File "/usr/local/lib/python2.7/dist-packages/ctypeslib/codegen/codegenerator.py", line 872, in generate_code
        parser.parse(srcfile)
      File "/usr/local/lib/python2.7/dist-packages/ctypeslib/codegen/clangparser.py", line 103, in parse
        self.tu = index.parse(filename, self.flags, options=self.tu_options)
      File "/usr/lib/python2.7/dist-packages/clang/cindex.py", line 2210, in parse
        self)
      File "/usr/lib/python2.7/dist-packages/clang/cindex.py", line 2322, in from_source
        raise TranslationUnitLoadError("Error parsing translation unit.")
    clang.cindex.TranslationUnitLoadError: Error parsing translation unit.
    failed
    

sstjohn avatar Dec 20 '16 15:12 sstjohn

  • [x] clang-args options needs quote and/or equal
  • [x] include-library typo (374f6e763e9ca511e1ec779361ce4936e8159f47)
  • [x] howto include multiple libraries
  • [ ] what does option do ?

trolldbois avatar May 01 '17 03:05 trolldbois