Giter VIP home page Giter VIP logo

c2ffi's People

Contributors

alex-sitnikov avatar attila-lendvai avatar borodust avatar hjudt avatar jarhmander avatar pfalcon avatar rpav avatar skissane avatar spaceotter avatar vaartis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

c2ffi's Issues

Building in Windows

I've successfully build llvm and then generated Visual Studio project files for c2ffi with CMake on Windows.
While building I got many errors like this one:
"error : unknown type name 'off_t'; did you mean '_off_t'?"

Is there any possibility to build c2ffi under windows or this is fundamentally impossible?

Having trouble running configure script in FreeBSD 10.0-Release

When I run autogen with 'bash autogen', I get the following output:
Processing ....
configure.ac:11: installing './compile'
configure.ac:25: installing './config.guess'
configure.ac:25: installing './config.sub'
configure.ac:14: installing './install-sh'
configure.ac:14: installing './missing'
Makefile.am: installing './INSTALL'
src/Makefile.am:34: warning: source file 'drivers/Sexp.cpp' is in a subdirectory,
src/Makefile.am:34: but option 'subdir-objects' is disabled
automake-1.14: warning: possible forward-incompatibility.
automake-1.14: At least a source file is in a subdirectory, but the 'subdir-objects'
automake-1.14: automake option hasn't been enabled. For now, the corresponding output
automake-1.14: object file(s) will be placed in the top-level directory. However,
automake-1.14: this behaviour will change in future Automake versions: they will
automake-1.14: unconditionally cause object files to be placed in the same subdirectory
automake-1.14: of the corresponding sources.
automake-1.14: You are advised to start using 'subdir-objects' option throughout your
automake-1.14: project, to avoid future incompatibilities.
src/Makefile.am:34: warning: source file 'drivers/JSON.cpp' is in a subdirectory,
src/Makefile.am:34: but option 'subdir-objects' is disabled
src/Makefile.am:34: warning: source file 'drivers/Null.cpp' is in a subdirectory,
src/Makefile.am:34: but option 'subdir-objects' is disabled
src/Makefile.am: installing './depcomp'

Afterwards I create and change into a build directory and run '../configure --prefix=/usr/local' which gets me this error message:
checking for clang... clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
checking whether clang understands -c and -o together... yes
checking for clang++... clang++
checking whether we are using the GNU C++ compiler... yes
checking whether clang++ accepts -g... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
cannot open /home/csegale/missing: No such file or directory
configure: WARNING: 'missing' script is too old or missing
checking for a thread-safe mkdir -p... ../install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... nawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking whether make supports nested variables... yes
checking dependency style of clang... gcc3
checking dependency style of clang++... gcc3
checking whether make supports nested variables... (cached) yes
checking how to run the C preprocessor... clang -E
checking whether ln -s works... yes
checking whether make sets $(MAKE)... (cached) yes
checking build system type... amd64-unknown-freebsd10.0
checking host system type... amd64-unknown-freebsd10.0
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by clang... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking the maximum length of command line arguments... 196608
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... no
checking how to convert amd64-unknown-freebsd10.0 file names to amd64-unknown-freebsd10.0 format... func_convert_file_noop
checking how to convert amd64-unknown-freebsd10.0 file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @file support... no
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from clang object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if clang supports -fno-rtti -fno-exceptions... yes
checking for clang option to produce PIC... -fPIC -DPIC
checking if clang PIC flag -fPIC -DPIC works... yes
checking if clang static flag -static works... yes
checking if clang supports -c -o file.o... yes
checking if clang supports -c -o file.o... (cached) yes
checking whether the clang linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... freebsd10.0 ld.so
checking how to hardcode library paths into programs... immediate
checking for shl_load... no
checking for shl_load in -ldld... no
checking for dlopen... yes
checking whether a program can dlopen itself... yes
checking whether a statically linked program can dlopen itself... no
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking how to run the C++ preprocessor... clang++ -E
checking for ld used by clang++... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking whether the clang++ linker (/usr/bin/ld) supports shared libraries... yes
checking for clang++ option to produce PIC... -fPIC -DPIC
checking if clang++ PIC flag -fPIC -DPIC works... yes
checking if clang++ static flag -static works... yes
checking if clang++ supports -c -o file.o... yes
checking if clang++ supports -c -o file.o... (cached) yes
checking whether the clang++ linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... freebsd10.0 ld.so
checking how to hardcode library paths into programs... immediate
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... no
checking whether pthreads work with -Kthread... no
checking whether pthreads work with -kthread... no
checking for the pthreads library -llthread... no
checking whether pthreads work with -pthread... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... -D_THREAD_SAFE
checking for PTHREAD_PRIO_INHERIT... yes
checking for dlopen in -ldl... no
configure: error: -ldl not found

From my understanding, dlopen in freebsd uses the libc as opposed to libdl. Is there any way to fix or work around this?

Building c2ffi with current clang

Is there any chance to update c2ffi to a more recent version of clang?
On Debian/testing it's pretty much impossible to keep multiple vesions
of clang/llvm installed in parallel. A build with clang-3.4 fails:

make --no-print-directory all-recursive
Making all in src
Making all in include
Making all in c2ffi
make[4]: Nothing to be done for all'. make[4]: Nothing to be done forall-am'.
Making all in test
make[3]: Nothing to be done for `all'.
CXX c2ffi-c2ffi.o
CXX c2ffi-init.o
CXX c2ffi-options.o
In file included from ../../src/c2ffi.cpp:27:
In file included from /usr/lib/llvm-3.4/include/clang/Frontend/TextDiagnosticPrinter.h:18:
/usr/lib/llvm-3.4/include/clang/Basic/Diagnostic.h:865:44: error: expected ';' at end of declaration list
void operator=(const DiagnosticBuilder &) LLVM_DELETED_FUNCTION;
^
;
/usr/lib/llvm-3.4/include/clang/Basic/Diagnostic.h:1226:3: error: unknown type name 'LLVM_EXPLICIT'
LLVM_EXPLICIT operator bool() const { return Message.size() > 0; }
^
In file included from ../../src/c2ffi.cpp:28:
In file included from /usr/lib/llvm-3.4/include/clang/Frontend/CompilerInstance.h:14:
In file included from /usr/lib/llvm-3.4/include/clang/Basic/SourceManager.h:38:
/usr/lib/llvm-3.4/include/clang/Basic/FileManager.h:66:18: error: no type named 'UniqueID' in namespace 'llvm::sys::fs'
llvm::sys::fs::UniqueID UniqueID;

/usr/lib/llvm-3.4/include/clang/Basic/FileManager.h:76:28: error: no type named 'UniqueID' in namespace 'llvm::sys::fs'
  FileEntry(llvm::sys::fs::UniqueID UniqueID, bool IsNamedPipe, bool InPCH)
            ~~~~~~~~~~~~~~~^
/usr/lib/llvm-3.4/include/clang/Basic/FileManager.h:98:24: error: no type named 'UniqueID' in namespace 'llvm::sys::fs'
  const llvm::sys::fs::UniqueID &getUniqueID() const { return UniqueID; }
        ~~~~~~~~~~~~~~~^
In file included from ../../src/c2ffi.cpp:28:
In file included from /usr/lib/llvm-3.4/include/clang/Frontend/CompilerInstance.h:14:
In file included from /usr/lib/llvm-3.4/include/clang/Basic/SourceManager.h:47:
/usr/lib/llvm-3.0/include/llvm/ADT/PointerUnion.h:266:22: error: use 'template' keyword to treat 'is' as a dependent template name
      return Ty(Val).is<T>();
                     ^
                     template
/usr/lib/llvm-3.0/include/llvm/ADT/PointerUnion.h:279:22: error: use 'template' keyword to treat 'get' as a dependent template name
      return Ty(Val).get<T>();
                     ^
                     template
In file included from ../../src/c2ffi.cpp:28:
In file included from /usr/lib/llvm-3.4/include/clang/Frontend/CompilerInstance.h:14:
/usr/lib/llvm-3.4/include/clang/Basic/SourceManager.h:224:53: error: expected ';' at end of declaration list
    ContentCache &operator=(const ContentCache& RHS) LLVM_DELETED_FUNCTION;
                                                    ^
                                                    ;
/usr/lib/llvm-3.4/include/clang/Basic/SourceManager.h:693:47: error: expected ';' at end of declaration list
  explicit SourceManager(const SourceManager&) LLVM_DELETED_FUNCTION;
                                              ^
                                              ;
/usr/lib/llvm-3.4/include/clang/Basic/SourceManager.h:694:39: error: expected ';' at end of declaration list
  void operator=(const SourceManager&) LLVM_DELETED_FUNCTION;
                                      ^
                                      ;
In file included from ../../src/c2ffi.cpp:28:
/usr/lib/llvm-3.4/include/clang/Frontend/CompilerInstance.h:141:45: error: expected ';' at end of declaration list
  CompilerInstance(const CompilerInstance &) LLVM_DELETED_FUNCTION;
                                            ^
                                            ;
/usr/lib/llvm-3.4/include/clang/Frontend/CompilerInstance.h:142:43: error: expected ';' at end of declaration list
  void operator=(const CompilerInstance &) LLVM_DELETED_FUNCTION;
                                          ^
                                          ;
/usr/lib/llvm-3.4/include/clang/Frontend/CompilerInstance.h:398:49: error: no member named 'isValid' in 'llvm::OwningPtr<clang::ASTConsumer>'
  bool hasASTConsumer() const { return Consumer.isValid(); }
                                       ~~~~~~~~ ^
/usr/lib/llvm-3.4/include/clang/Frontend/CompilerInstance.h:416:41: error: no member named 'isValid' in 'llvm::OwningPtr<clang::Sema>'
  bool hasSema() const { return TheSema.isValid(); }
                                ~~~~~~~ ^
/usr/lib/llvm-3.4/include/clang/Frontend/CompilerInstance.h:437:31: error: no member named 'isValid' in 'llvm::OwningPtr<clang::CodeCompleteConsumer>'
    return CompletionConsumer.isValid();
           ~~~~~~~~~~~~~~~~~~ ^
/usr/lib/llvm-3.4/include/clang/Frontend/CompilerInstance.h:460:56: error: no member named 'isValid' in 'llvm::OwningPtr<llvm::Timer>'
  bool hasFrontendTimer() const { return FrontendTimer.isValid(); }
                                         ~~~~~~~~~~~~~ ^
In file included from ../../src/c2ffi.cpp:33:
In file included from /usr/lib/llvm-3.4/include/clang/Lex/HeaderSearch.h:17:
In file included from /usr/lib/llvm-3.4/include/clang/Lex/DirectoryLookup.h:19:
/usr/lib/llvm-3.4/include/clang/Lex/ModuleMap.h:99:5: error: unknown type name 'LLVM_EXPLICIT'
    LLVM_EXPLICIT operator bool() const { return Storage.getPointer() != 0; }
    ^
In file included from ../../src/c2ffi.cpp:33:
/usr/lib/llvm-3.4/include/clang/Lex/HeaderSearch.h:236:36: error: expected ';' at end of declaration list
  HeaderSearch(const HeaderSearch&) LLVM_DELETED_FUNCTION;
                                   ^
                                   ;
/usr/lib/llvm-3.4/include/clang/Lex/HeaderSearch.h:237:38: error: expected ';' at end of declaration list
  void operator=(const HeaderSearch&) LLVM_DELETED_FUNCTION;
                                     ^
                                     ;
fatal error: too many errors emitted, stopping now [-ferror-limit=]
In file included from ../../src/init.cpp:27:
In file included from /usr/lib/llvm-3.4/include/clang/Frontend/TextDiagnosticPrinter.h:18:
/usr/lib/llvm-3.4/include/clang/Basic/Diagnostic.h:865:44: error: expected ';' at end of declaration list
  void operator=(const DiagnosticBuilder &) LLVM_DELETED_FUNCTION;
                                           ^
                                           ;
In file included from ../../src/options.cpp:27:
In file included from ../../src/include/c2ffi.h:96:
In file included from ../../src/include/c2ffi/type.h:30:
In file included from /usr/lib/llvm-3.4/include/clang/AST/Type.h:17:
In file included from /usr/lib/llvm-3.4/include/clang/AST/NestedNameSpecifier.h:17:
/usr/lib/llvm-3.4/include/clang/Basic/Diagnostic.h:865:44: error: expected ';' at end of declaration list
  void operator=(const DiagnosticBuilder &) LLVM_DELETED_FUNCTION;
                                           ^
                                           ;
/usr/lib/llvm-3.4/include/clang/Basic/Diagnostic.h:1226:3: error: unknown type name 'LLVM_EXPLICIT'
  LLVM_EXPLICIT operator bool() const { return Message.size() > 0; }
  ^
/usr/lib/llvm-3.4/include/clang/Basic/Diagnostic.h:1226:3: error: unknown type name 'LLVM_EXPLICIT'
  LLVM_EXPLICIT operator bool() const { return Message.size() > 0; }
  ^
In file included from ../../src/options.cpp:27:
In file included from ../../src/include/c2ffi.h:96:
In file included from ../../src/include/c2ffi/type.h:30:
In file included from /usr/lib/llvm-3.4/include/clang/AST/Type.h:17:
/usr/lib/llvm-3.4/include/clang/AST/NestedNameSpecifier.h:100:46: error: expected ';' at end of declaration list
  void operator=(const NestedNameSpecifier &) LLVM_DELETED_FUNCTION;
                                             ^
                                             ;
/usr/lib/llvm-3.4/include/clang/AST/NestedNameSpecifier.h:234:3: error: unknown type name 'LLVM_EXPLICIT'
  LLVM_EXPLICIT operator bool() const { return Qualifier; }
  ^
/usr/lib/llvm-3.4/include/clang/AST/NestedNameSpecifier.h:255:37: error: expected ';' at end of declaration list
  SourceRange getSourceRange() const LLVM_READONLY;
                                    ^
                                    ;
/usr/lib/llvm-3.4/include/clang/AST/NestedNameSpecifier.h:437:37: error: expected ';' at end of declaration list
  SourceRange getSourceRange() const LLVM_READONLY {
                                    ^
                                    ;
In file included from ../../src/options.cpp:27:
In file included from ../../src/include/c2ffi.h:96:
In file included from ../../src/include/c2ffi/type.h:30:
In file included from /usr/lib/llvm-3.4/include/clang/AST/Type.h:18:
In file included from /usr/lib/llvm-3.4/include/clang/AST/TemplateName.h:20:
/usr/lib/llvm-3.0/include/llvm/ADT/PointerUnion.h:266:22: error: use 'template' keyword to treat 'is' as a dependent template name
      return Ty(Val).is<T>();
                     ^
                     template
/usr/lib/llvm-3.0/include/llvm/ADT/PointerUnion.h:279:22: error: use 'template' keyword to treat 'get' as a dependent template name
      return Ty(Val).get<T>();
                     ^
                     template
In file included from ../../src/options.cpp:27:
In file included from ../../src/include/c2ffi.h:96:
In file included from ../../src/include/c2ffi/type.h:30:
In file included from /usr/lib/llvm-3.4/include/clang/AST/Type.h:21:
/usr/lib/llvm-3.4/include/clang/Basic/IdentifierTable.h:79:40: error: expected ';' at end of declaration list
  IdentifierInfo(const IdentifierInfo&) LLVM_DELETED_FUNCTION;
                                       ^
                                       ;
/usr/lib/llvm-3.4/include/clang/Basic/IdentifierTable.h:80:40: error: expected ';' at end of declaration list
  void operator=(const IdentifierInfo&) LLVM_DELETED_FUNCTION;
                                       ^
                                       ;
/usr/lib/llvm-3.4/include/clang/Basic/IdentifierTable.h:358:49: error: expected ';' at end of declaration list
  IdentifierIterator(const IdentifierIterator &) LLVM_DELETED_FUNCTION;
                                                ^
                                                ;
/usr/lib/llvm-3.4/include/clang/Basic/IdentifierTable.h:359:45: error: expected ';' at end of declaration list
  void operator=(const IdentifierIterator &) LLVM_DELETED_FUNCTION;
                                            ^
                                            ;
/usr/lib/llvm-3.4/include/clang/Basic/IdentifierTable.h:721:39: error: expected ';' at end of declaration list
  SelectorTable(const SelectorTable &) LLVM_DELETED_FUNCTION;
                                      ^
                                      ;
/usr/lib/llvm-3.4/include/clang/Basic/IdentifierTable.h:722:40: error: expected ';' at end of declaration list
  void operator=(const SelectorTable &) LLVM_DELETED_FUNCTION;
                                       ^
                                       ;
In file included from ../../src/init.cpp:28:
In file included from /usr/lib/llvm-3.4/include/clang/Frontend/CompilerInstance.h:14:
In file included from /usr/lib/llvm-3.4/include/clang/Basic/SourceManager.h:38:
/usr/lib/llvm-3.4/include/clang/Basic/FileManager.h:66:18: error: no type named 'UniqueID' in namespace 'llvm::sys::fs'
  llvm::sys::fs::UniqueID UniqueID;
  ~~~~~~~~~~~~~~~^
/usr/lib/llvm-3.4/include/clang/Basic/FileManager.h:76:28: error: no type named 'UniqueID' in namespace 'llvm::sys::fs'
  FileEntry(llvm::sys::fs::UniqueID UniqueID, bool IsNamedPipe, bool InPCH)
            ~~~~~~~~~~~~~~~^
/usr/lib/llvm-3.4/include/clang/Basic/FileManager.h:98:24: error: no type named 'UniqueID' in namespace 'llvm::sys::fs'
  const llvm::sys::fs::UniqueID &getUniqueID() const { return UniqueID; }
        ~~~~~~~~~~~~~~~^
In file included from ../../src/init.cpp:28:
In file included from /usr/lib/llvm-3.4/include/clang/Frontend/CompilerInstance.h:14:
In file included from /usr/lib/llvm-3.4/include/clang/Basic/SourceManager.h:47:
/usr/lib/llvm-3.0/include/llvm/ADT/PointerUnion.h:266:22: error: use 'template' keyword to treat 'is' as a dependent template name
      return Ty(Val).is<T>();
                     ^
                     template
/usr/lib/llvm-3.0/include/llvm/ADT/PointerUnion.h:279:22: error: use 'template' keyword to treat 'get' as a dependent template name
      return Ty(Val).get<T>();
                     ^
                     template
In file included from ../../src/init.cpp:28:
In file included from /usr/lib/llvm-3.4/include/clang/Frontend/CompilerInstance.h:14:
/usr/lib/llvm-3.4/include/clang/Basic/SourceManager.h:224:53: error: expected ';' at end of declaration list
    ContentCache &operator=(const ContentCache& RHS) LLVM_DELETED_FUNCTION;
                                                    ^
                                                    ;
In file included from ../../src/options.cpp:27:
In file included from ../../src/include/c2ffi.h:96:
In file included from ../../src/include/c2ffi/type.h:30:
/usr/lib/llvm-3.4/include/clang/AST/Type.h:444:3: error: unknown type name 'LLVM_EXPLICIT'
  LLVM_EXPLICIT operator bool() const { return hasQualifiers(); }
  ^
/usr/lib/llvm-3.4/include/clang/Basic/SourceManager.h:693:47: error: expected ';' at end of declaration list
  explicit SourceManager(const SourceManager&) LLVM_DELETED_FUNCTION;
                                              ^
                                              ;
/usr/lib/llvm-3.4/include/clang/Basic/SourceManager.h:694:39: error: expected ';' at end of declaration list
  void operator=(const SourceManager&) LLVM_DELETED_FUNCTION;
                                      ^
                                      ;
/usr/lib/llvm-3.4/include/clang/AST/Type.h:1167:21: error: expected ';' at end of declaration list
  Type(const Type &) LLVM_DELETED_FUNCTION;
                    ^
                    ;
/usr/lib/llvm-3.4/include/clang/AST/Type.h:1168:31: error: expected ';' at end of declaration list
  void operator=(const Type &) LLVM_DELETED_FUNCTION;
                              ^
                              ;
/usr/lib/llvm-3.4/include/clang/AST/Type.h:4585:5: error: cannot initialize object parameter of type 'clang::Qualifiers' with an expression of type 'clang::QualifierCollector'
    addFastQualifiers(type.getLocalFastQualifiers());
    ^~~~~~~~~~~~~~~~~
/usr/lib/llvm-3.4/include/clang/AST/Type.h:4590:5: error: cannot initialize object parameter of type 'clang::Qualifiers' with an expression of type 'clang::QualifierCollector'
    addConsistentQualifiers(extQuals->getQualifiers());
    ^~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../src/init.cpp:28:
/usr/lib/llvm-3.4/include/clang/Frontend/CompilerInstance.h:141:45: error: expected ';' at end of declaration list
  CompilerInstance(const CompilerInstance &) LLVM_DELETED_FUNCTION;
                                            ^
                                            ;
/usr/lib/llvm-3.4/include/clang/Frontend/CompilerInstance.h:142:43: error: expected ';' at end of declaration list
  void operator=(const CompilerInstance &) LLVM_DELETED_FUNCTION;
                                          ^
                                          ;
fatal error: too many errors emitted, stopping now [-ferror-limit=]
/usr/lib/llvm-3.4/include/clang/Frontend/CompilerInstance.h:398:49: error: no member named 'isValid' in 'llvm::OwningPtr<clang::ASTConsumer>'
  bool hasASTConsumer() const { return Consumer.isValid(); }
                                       ~~~~~~~~ ^
/usr/lib/llvm-3.4/include/clang/Frontend/CompilerInstance.h:416:41: error: no member named 'isValid' in 'llvm::OwningPtr<clang::Sema>'
  bool hasSema() const { return TheSema.isValid(); }
                                ~~~~~~~ ^
/usr/lib/llvm-3.4/include/clang/Frontend/CompilerInstance.h:437:31: error: no member named 'isValid' in 'llvm::OwningPtr<clang::CodeCompleteConsumer>'
    return CompletionConsumer.isValid();
           ~~~~~~~~~~~~~~~~~~ ^
/usr/lib/llvm-3.4/include/clang/Frontend/CompilerInstance.h:460:56: error: no member named 'isValid' in 'llvm::OwningPtr<llvm::Timer>'
  bool hasFrontendTimer() const { return FrontendTimer.isValid(); }
                                         ~~~~~~~~~~~~~ ^
In file included from ../../src/init.cpp:34:
In file included from /usr/lib/llvm-3.4/include/clang/Lex/HeaderSearch.h:17:
In file included from /usr/lib/llvm-3.4/include/clang/Lex/DirectoryLookup.h:19:
/usr/lib/llvm-3.4/include/clang/Lex/ModuleMap.h:99:5: error: unknown type name 'LLVM_EXPLICIT'
    LLVM_EXPLICIT operator bool() const { return Storage.getPointer() != 0; }
    ^
In file included from ../../src/init.cpp:34:
/usr/lib/llvm-3.4/include/clang/Lex/HeaderSearch.h:236:36: error: expected ';' at end of declaration list
  HeaderSearch(const HeaderSearch&) LLVM_DELETED_FUNCTION;
                                   ^
                                   ;
/usr/lib/llvm-3.4/include/clang/Lex/HeaderSearch.h:237:38: error: expected ';' at end of declaration list
  void operator=(const HeaderSearch&) LLVM_DELETED_FUNCTION;
                                     ^
                                     ;
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[3]: *** [c2ffi-c2ffi.o] Error 1
make[3]: *** Waiting for unfinished jobs....
20 errors generated.
make[3]: *** [c2ffi-options.o] Error 1
20 errors generated.
make[3]: *** [c2ffi-init.o] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

TIA, Ralf Mattes

Can't build.

c2ffi.cpp:86:27: error: no viable conversion from 'std::unique_ptrclang::ASTConsumer' to
'clang::ASTConsumer *'
ci.setASTConsumer(std::unique_ptrclang::ASTConsumer(astc));

Make path to llvm-config configurable

Currently, configure calls llvm-config assuming it can be found in $PATH.
This will fail with some Linux distributions that support multiple versions of llvm/clang
(Debian installs llvm-config-3.n for n=0...6).
It might be a good idea to extend configure.ac with a --with-llvm-configswitch to explicitly set the path of that script.

Compilation errors for 'master' branch using clang-3.5 on Ubuntu 14.04

Goes like this:

../../src/init.cpp:95:10: error: no member named 'shared_ptr' in namespace 'std'
std::shared_ptr<TargetOptions> pto =
~~~~~^
../../src/init.cpp:95:21: error: 'TargetOptions' does not refer to a value
std::shared_ptr<TargetOptions> pto =
                ^
/usr/lib/llvm-3.5/include/clang/Basic/TargetOptions.h:26:7: note: declared here
class TargetOptions : public RefCountedBase<TargetOptions> {
       ^
../../src/init.cpp:95:36: error: use of undeclared identifier 'pto'
std::shared_ptr<TargetOptions> pto =
                               ^
../../src/init.cpp:96:14: error: no member named 'shared_ptr' in namespace 'std'
    std::shared_ptr<TargetOptions>(new TargetOptions());
    ~~~~~^
../../src/init.cpp:96:25: error: 'TargetOptions' does not refer to a value
    std::shared_ptr<TargetOptions>(new TargetOptions());
                    ^
/usr/lib/llvm-3.5/include/clang/Basic/TargetOptions.h:26:7: note: declared here  
class TargetOptions : public RefCountedBase<TargetOptions> {
  ^
../../src/init.cpp:98:9: error: use of undeclared identifier 'pto'
    pto->Triple = llvm::sys::getDefaultTargetTriple();
    ^
../../src/init.cpp:100:9: error: use of undeclared identifier 'pto'
    pto->Triple = c.arch;
    ^
../../src/init.cpp:102:73: error: use of undeclared identifier 'pto'; did you mean 'pti'?
TargetInfo *pti = TargetInfo::CreateTargetInfo(ci.getDiagnostics(), pto);
                                                                    ^~~
                                                                    pti
../../src/init.cpp:102:17: note: 'pti' declared here
TargetInfo *pti = TargetInfo::CreateTargetInfo(ci.getDiagnostics(), pto);
            ^
../../src/init.cpp:102:73: error: cannot initialize a parameter of type 'clang::TargetOptions *' with an     lvalue of type 'clang::TargetInfo *'
TargetInfo *pti = TargetInfo::CreateTargetInfo(ci.getDiagnostics(), pto);
                                                                    ^~~
/usr/lib/llvm-3.5/include/clang/Basic/TargetInfo.h:98:54: note: passing argument to parameter 'Opts' here
                                  TargetOptions *Opts);
                                                 ^
../../src/init.cpp:107:27: error: too many arguments to function call, expected 0, have 1
ci.createPreprocessor(clang::TU_Complete);
~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~
/usr/lib/llvm-3.5/include/clang/Frontend/CompilerInstance.h:562:3: note: 'createPreprocessor' declared here
void createPreprocessor();
^
10 errors generated.

configure.ac checks llvm version incorrectly

After the configure.ac checks the version of llvm with llvm-config --version, it then has a shell script snippet that reports a failure if the version of llvm is exactly 3.3, which, judging by the failure message is not what you want. Any higher or lower version of llvm will work now. diff below will reverse this so only version 3.3 will work:

diff --git a/configure.ac b/configure.ac
index 3123eec..e535d6a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,7 +56,7 @@ AC_ARG_ENABLE(debug, [ --enable-debug enable debuggi

AC_MSG_CHECKING([for llvm >= 3.3])
AS_VERSION_COMPARE(llvm-config --version, [3.3], [ver_check=-1], [ver_check=0
-if ! test $ver_check -ne 0; then
+if test $ver_check -ne 0; then
AC_MSG_RESULT([no])
AC_MSG_FAILURE([version 3.3 required], 1)
else

Building on OS X

I'm trying to build c2ffi on OS X 10.10.3.

I built LLVM and Clang from the repositories.

> llvm-config --version
3.8.0svn

> clang --version
clang version 3.8.0 (trunk 244716)
Target: x86_64-apple-darwin14.3.0
Thread model: posix
InstalledDir: /Users/simon/projects/llvm-build/bin

When I run

../configure

I get:

[...]
checking for llvm >= 3.5... yes
checking clang/Frontend/CompilerInstance.h usability... no
checking clang/Frontend/CompilerInstance.h presence... no
checking for clang/Frontend/CompilerInstance.h... no
configure: error: clang development libs not found

In my case the headers for clang are found in /Users/simon/projects/llvm/tools/clang/include. As indicated by the docs, I specify LIBCLANG_CPPFLAGS. I do so in my .bashrc like this:

export LIBCLANG_CPPFLAGS=/Users/simon/projects/llvm/tools/clang/include

That didn't work. I checked

> llvm-config --cxxflags
-I/Users/simon/projects/llvm/include -I/Users/simon/projects/llvm-build/include  -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -std=c++11   -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS

> llvm-config --ldflags
-L/Users/simon/projects/llvm-build//lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names

> llvm-config --libs
-lLLVMLTO -lLLVMObjCARCOpts -lLLVMLinker -lLLVMBitWriter -lLLVMIRReader -lLLVMXCoreDisassembler -lLLVMXCoreCodeGen -lLLVMXCoreDesc -lLLVMXCoreInfo -lLLVMXCoreAsmPrinter -lLLVMSystemZDisassembler -lLLVMSystemZCodeGen -lLLVMSystemZAsmParser -lLLVMSystemZDesc -lLLVMSystemZInfo -lLLVMSystemZAsmPrinter -lLLVMSparcDisassembler -lLLVMSparcCodeGen -lLLVMSparcAsmParser -lLLVMSparcDesc -lLLVMSparcInfo -lLLVMSparcAsmPrinter -lLLVMPowerPCDisassembler -lLLVMPowerPCCodeGen -lLLVMPowerPCAsmParser -lLLVMPowerPCDesc -lLLVMPowerPCInfo -lLLVMPowerPCAsmPrinter -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMNVPTXAsmPrinter -lLLVMMSP430CodeGen -lLLVMMSP430Desc -lLLVMMSP430Info -lLLVMMSP430AsmPrinter -lLLVMMipsDisassembler -lLLVMMipsCodeGen -lLLVMMipsAsmParser -lLLVMMipsDesc -lLLVMMipsInfo -lLLVMMipsAsmPrinter -lLLVMHexagonDisassembler -lLLVMHexagonCodeGen -lLLVMHexagonDesc -lLLVMHexagonInfo -lLLVMCppBackendCodeGen -lLLVMCppBackendInfo -lLLVMBPFCodeGen -lLLVMBPFDesc -lLLVMBPFInfo -lLLVMBPFAsmPrinter -lLLVMARMDisassembler -lLLVMARMCodeGen -lLLVMARMAsmParser -lLLVMARMDesc -lLLVMARMInfo -lLLVMARMAsmPrinter -lLLVMAMDGPUCodeGen -lLLVMAMDGPUAsmParser -lLLVMAMDGPUUtils -lLLVMAMDGPUDesc -lLLVMAMDGPUInfo -lLLVMAMDGPUAsmPrinter -lLLVMAArch64Disassembler -lLLVMAArch64CodeGen -lLLVMAArch64AsmParser -lLLVMAArch64Desc -lLLVMAArch64Info -lLLVMAArch64AsmPrinter -lLLVMAArch64Utils -lLLVMMIRParser -lLLVMAsmParser -lLLVMLibDriver -lLLVMOption -lLLVMDebugInfoPDB -lgtest_main -lgtest -lLLVMTableGen -lLLVMOrcJIT -lLLVMLineEditor -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMX86Desc -lLLVMMCDisassembler -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMMCJIT -lLLVMDebugInfoDWARF -lLLVMPasses -lLLVMipo -lLLVMVectorize -lLLVMInterpreter -lLLVMExecutionEngine -lLLVMRuntimeDyld -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMInstCombine -lLLVMInstrumentation -lLLVMTransformUtils -lLLVMipa -lLLVMMC -lLLVMAnalysis -lLLVMCore -lLLVMSupport

The path to clang headers isn't included there, so I created a symlink into a folder included by llvm-config --cxxflags that points to clang:

> ls -l /Users/simon/projects/llvm-build/include
total 8
lrwxr-xr-x  1 simon  staff   52 Aug 13 07:09 clang -> /Users/simon/projects/llvm/tools/clang/include/clang
drwxr-xr-x  9 simon  staff  306 Aug 12 07:59 llvm

That didn't work either.

Finally, I checked that clang/Frontend/CompilerInstance.h and libclangFrontend.a exist in included directories:

> find -L /Users/simon/projects/llvm-build/include -name CompilerInstance.h
/Users/simon/projects/llvm-build/include/clang/Frontend/CompilerInstance.h

> find -L /Users/simon/projects/llvm-build//lib -name libclangFrontend.a
/Users/simon/projects/llvm-build//lib/libclangFrontend.a

The headers and libraries are there, but still configure refuses to find it. Could you please suggest how to build c2ffi on OS X?

Build fail with llvm 4.0.1

With msys2 mingw64 environment:
git:

$git branch
* llvm-4.0.0

clang

$clang.exe --version
clang version 4.0.1 (https://llvm.org/git/clang 3c8961bedc65c9a15cbe67a2ef385a0938f7cfef) (http://llvm.org/git/llvm c8fccc53ed66d505898f8850bcc690c977a7c9a7)
Target: x86_64-w64-windows-gnu
Thread model: posix

Build log:

$ cmake --build .
Scanning dependencies of target c2ffi
[  7%] Building CXX object CMakeFiles/c2ffi.dir/src/AST.cpp.obj
[ 15%] Building CXX object CMakeFiles/c2ffi.dir/src/Decl.cpp.obj
[ 23%] Building CXX object CMakeFiles/c2ffi.dir/src/Expr.cpp.obj
[ 30%] Building CXX object CMakeFiles/c2ffi.dir/src/OutputDriver.cpp.obj
[ 38%] Building CXX object CMakeFiles/c2ffi.dir/src/Template.cpp.obj
[ 46%] Building CXX object CMakeFiles/c2ffi.dir/src/Type.cpp.obj
[ 53%] Building CXX object CMakeFiles/c2ffi.dir/src/c2ffi.cpp.obj
[ 61%] Building CXX object CMakeFiles/c2ffi.dir/src/init.cpp.obj
[ 69%] Building CXX object CMakeFiles/c2ffi.dir/src/options.cpp.obj
[ 76%] Building CXX object CMakeFiles/c2ffi.dir/src/drivers/JSON.cpp.obj
[ 84%] Building CXX object CMakeFiles/c2ffi.dir/src/drivers/Null.cpp.obj
[ 92%] Building CXX object CMakeFiles/c2ffi.dir/src/drivers/Sexp.cpp.obj
[100%] Linking CXX executable bin/c2ffi.exe
C:/msys64/opt/llvm40/lib/libclangDriver.a(MSVCToolChain.cpp.obj):MSVCToolChain.cpp:(.text+0x3e0b): undefined reference to `GetFileVersionInfoSizeW'
C:/msys64/opt/llvm40/lib/libclangDriver.a(MSVCToolChain.cpp.obj):MSVCToolChain.cpp:(.text+0x3e79): undefined reference to `GetFileVersionInfoW'
C:/msys64/opt/llvm40/lib/libclangDriver.a(MSVCToolChain.cpp.obj):MSVCToolChain.cpp:(.text+0x3ee9): undefined reference to `VerQueryValueW'
collect2.exe: error: ld returned 1 exit status

llvm 5.0?

Any plans to make this extremely useful tool build with clang/llvm 5.0? I ask because the 4.0 version currently required by this project is not easily installable on ArchLinux for reasons I don't understand. (It used to be available, but now only 5.0 and 3.9 and lower are available.)

https://www.archlinux.org/packages/?sort=&arch=x86_64&q=llvm

Question: Support for latest LLVM on Mac

I'm trying to build on Mac OS 10.14.2 (Mojave). I installed LLVM with homebrew and set LLVM_DIR to /usr/local/opt/llvm. When I run "cmake .." in the build directory, I get this error:

CMake Error at CMakeLists.txt:7 (find_package):
Could not find a configuration file for package "LLVM" that is compatible
with requested version "7.0".

The following configuration files were considered but not accepted:

/usr/local/opt/llvm/lib/cmake/llvm/LLVMConfig.cmake, version: 8.0.0
/usr/local/opt/llvm/lib/cmake/llvm/llvm-config.cmake, version: unknown

Do I need to install a different version?

c2ffi doesn't parse #if defined() #else #endif statements correctly

Background with using cl-autowrap on curl.h

I was working on providing more test cases for cl-autowrap and I was cleaning up the present set of tests. In the process of using libcurl to create another set of tests from wrapping curl.h, I noticed strange thing, probably a bug in c2ffi. Note that I build the libcurl fresh by creating a t_curl subdirectory in cl-autowrap and used the appropriate --use-prefix to install it in the t_curl subdirectory. In general, I think that the tests for cl-autowrap should be done this way so there are no issues with version numbers of the libraries being wrapped.

I first noticed this from the fact that cl-autowrap would not successfully wrap the libcurl functions like curl_easy_setopt or any of the curl_easy_xxxx type functions but it successfully wrapped most of the rest of the curl.h file. The difference seemed to be the fact that the declaration for curl_easy_setop had as its first argument CURL *handle. However if I manually changed the curl.h file and included a statement like:

#define CURL void

Then curl_easy_setopt was correctly wrapped. From this I decided to investigate the c2ffi output that feeds into cl-autowrap. In doing so, I found some strange behavior with conditional compile statements.

Investigation of applying c2ffi to curl.h

In the file curl.h near the beginning we have the following conditional compile statements:

#if defined(BUILDING_LIBCURL) || defined(CURL_STRICTER)
   typedef struct Curl_easy CURL;
   typedef struct Curl_share CURLSH;
#else
  typedef void CURL;
  typedef void CURLSH;
#endif

If I run the following command at the CLI:

c2ffi curl.h | grep easy

Then none of the curl_easy_xxxx functions show successful parsing. If I define CURL to be void, as mentioned in the last section, then they are all correctly parsed. Note that neither BUILDING_LIBCURL nor CURL_STRICT are defined and so this manual define should not be needed.

However, and here the plot thickens, if we repeat the above code twice in a row, the curl_easy_xxxx conditional statements are parsed correctly. Namely if we simply do this in curl.h:

#if defined(BUILDING_LIBCURL) || defined(CURL_STRICTER)
   typedef struct Curl_easy CURL;
   typedef struct Curl_share CURLSH;
#else
  typedef void CURL;
  typedef void CURLSH;
#endif

#if defined(BUILDING_LIBCURL) || defined(CURL_STRICTER)
   typedef struct Curl_easy CURL;
   typedef struct Curl_share CURLSH;
#else
  typedef void CURL;
  typedef void CURLSH;
#endif

Actually the second repetition can be modified with different types conditional statements and it still works. This means that the parsing is correctly making CURL be equivalent to void based on the second set of conditional statements but the first set of conditional statements doesn't do that, although it should.

Gentoo Clang 3.7.0 fails when building

Just trying to get this to build for the first time and get the following output.

I had attempted to build previously with an old clang and then updated and it still failed. After that I performed the commands you see in the output below.

clang --version =>

clang version 3.7.0 (tags/RELEASE_370/final)
Target: x86_64-pc-linux-gnu                                                                                                                                                                  
Thread model: posix
mordocai:build/ (masterโœ—) $ make clean                                                                                                                                             [2:11:46]
Making clean in src
Making clean in include
Making clean in c2ffi
rm -rf .libs _libs
rm -f *.lo
rm -rf .libs _libs
rm -f *.lo
Making clean in test
rm -rf .libs _libs
rm -f *.lo
 rm -f c2ffi
rm -rf .libs _libs
rm -f *.o
rm -f drivers/*.o
rm -f *.lo
rm -rf .libs _libs
rm -f *.lo
mordocai:build/ (masterโœ—) $ cd ..                                                                                                                                                  [2:11:49]
mordocai:c2ffi/ (masterโœ—) $ ls                                                                                                                                                     [2:11:50]
aclocal     autoclean       build      config.guess  config.sh   configure.ac  depcomp        install-sh   Makefile.am  NEWS       src
aclocal.m4  autogen         ChangeLog  config.h      config.sub  COPYING       gen-functions  ltmain.sh    Makefile.in  README     TODO
AUTHORS     autom4te.cache  compile    config.log    configure   defs.h.in     INSTALL        make-extras  missing      README.md
mordocai:c2ffi/ (masterโœ—) $ ./autoclean                                                                                                                                            [2:11:51]
WARNING: Cleaning out everything, proceed? (yes/no) yes
cleaning out Makefile.in's...
cleaning out backups...
cleaning out symlinks...
cleaning out other...
Make a tarball? (y/n) n
mordocai:c2ffi/ (master) $ ls                                                                                                                                                      [2:11:58]
aclocal  AUTHORS  autoclean  autogen  build  ChangeLog  config.h  config.sh  configure.ac  COPYING  gen-functions  make-extras  Makefile.am  NEWS  README  README.md  src  TODO
mordocai:c2ffi/ (master) $ ./autogen                                                                                                                                               [2:11:59]
Processing ....
aclocal-1.15: installing 'aclocal/libtool.m4' from '/usr/share/aclocal/libtool.m4'
aclocal-1.15: installing 'aclocal/ltoptions.m4' from '/usr/share/aclocal/ltoptions.m4'
aclocal-1.15: installing 'aclocal/ltsugar.m4' from '/usr/share/aclocal/ltsugar.m4'
aclocal-1.15: installing 'aclocal/ltversion.m4' from '/usr/share/aclocal/ltversion.m4'
aclocal-1.15: installing 'aclocal/lt~obsolete.m4' from '/usr/share/aclocal/lt~obsolete.m4'
configure.ac:11: installing './compile'
configure.ac:26: installing './config.guess'
configure.ac:26: installing './config.sub'
configure.ac:14: installing './install-sh'
configure.ac:14: installing './missing'
Makefile.am: installing './INSTALL'
src/Makefile.am: installing './depcomp'
mordocai:c2ffi/ (master) $ cd build                                                                                                                                                [2:12:11]
mordocai:build/ (master) $ ls                                                                                                                                                      [2:12:14]
config.log  config.status  defs.h  libtool  Makefile  src  stamp-h1
mordocai:build/ (master) $ rm -rf ./*                                                                                                                                              [2:12:15]
zsh: sure you want to delete all the files in /home/mordocai/git_repos/c2ffi/build/. [yn]? y
mordocai:build/ (master) $ ls                                                                                                                                                      [2:12:20]
mordocai:build/ (master) $ ../configure                                                                                                                                            [2:12:20]
checking for clang... clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
checking whether clang understands -c and -o together... yes
checking for clang++... clang++
checking whether we are using the GNU C++ compiler... yes
checking whether clang++ accepts -g... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking whether make supports nested variables... yes
checking dependency style of clang... gcc3
checking dependency style of clang++... gcc3
checking whether make supports nested variables... (cached) yes
checking how to run the C preprocessor... clang -E
checking whether clang++ supports C++11 features by default... no
checking whether clang++ supports C++11 features with -std=gnu++11... yes
checking whether ln -s works... yes
checking whether make sets $(MAKE)... (cached) yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by clang... /usr/bin/x86_64-pc-linux-gnu-ld
checking if the linker (/usr/bin/x86_64-pc-linux-gnu-ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking the maximum length of command line arguments... 1635000
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/x86_64-pc-linux-gnu-ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from clang object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if clang supports -fno-rtti -fno-exceptions... yes
checking for clang option to produce PIC... -fPIC -DPIC
checking if clang PIC flag -fPIC -DPIC works... yes
checking if clang static flag -static works... yes
checking if clang supports -c -o file.o... yes
checking if clang supports -c -o file.o... (cached) yes
checking whether the clang linker (/usr/bin/x86_64-pc-linux-gnu-ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for shl_load... no
checking for shl_load in -ldld... no
checking for dlopen... no
checking for dlopen in -ldl... yes
checking whether a program can dlopen itself... yes
checking whether a statically linked program can dlopen itself... no
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking how to run the C++ preprocessor... clang++ -E
checking for ld used by clang++... /usr/bin/x86_64-pc-linux-gnu-ld -m elf_x86_64
checking if the linker (/usr/bin/x86_64-pc-linux-gnu-ld -m elf_x86_64) is GNU ld... yes
checking whether the clang++ linker (/usr/bin/x86_64-pc-linux-gnu-ld -m elf_x86_64) supports shared libraries... yes
checking for clang++ option to produce PIC... -fPIC -DPIC
checking if clang++ PIC flag -fPIC -DPIC works... yes
checking if clang++ static flag -static works... yes
checking if clang++ supports -c -o file.o... yes
checking if clang++ supports -c -o file.o... (cached) yes
checking whether the clang++ linker (/usr/bin/x86_64-pc-linux-gnu-ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking if compiler needs -Werror to reject unknown flags... yes
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... no
checking whether pthreads work with -Kthread... no
checking whether pthreads work with -kthread... no
checking for the pthreads library -llthread... no
checking whether pthreads work with -pthread... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... no
checking for PTHREAD_PRIO_INHERIT... yes
checking for dlopen in -lc... no
checking for dlopen in -ldl... (cached) yes
checking for setupterm in -lcurses... yes
checking for compress in -lz... yes
checking for ANSI C header files... (cached) yes
checking libintl.h usability... yes
checking libintl.h presence... yes
checking for libintl.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking for stdlib.h... (cached) yes
checking for sys/types.h... (cached) yes
checking for int8_t... yes
checking for int16_t... yes
checking for int32_t... yes
checking for int64_t... yes
checking for u_int8_t... yes
checking for u_int16_t... yes
checking for u_int32_t... yes
checking for u_int64_t... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking for getopt_long... yes
checking whether byte ordering is bigendian... no
checking for llvm >= 3.5... yes
checking clang/Frontend/CompilerInstance.h usability... yes
checking clang/Frontend/CompilerInstance.h presence... yes
checking for clang/Frontend/CompilerInstance.h... yes
checking for main in -lclangFrontend... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/include/c2ffi/Makefile
config.status: creating src/include/Makefile
config.status: creating src/Makefile
config.status: creating src/test/Makefile
config.status: creating defs.h
config.status: executing depfiles commands
config.status: executing libtool commands
mordocai:build/ (master) $ make                                                                                                                                                    [2:12:32]
(CDPATH="${ZSH_VERSION+.}:" && cd .. && /bin/sh /home/mordocai/git_repos/c2ffi/missing autoheader)
rm -f stamp-h1
touch ../defs.h.in
cd . && /bin/sh ./config.status defs.h
config.status: creating defs.h
config.status: defs.h is unchanged
make --no-print-directory all-recursive
Making all in src
Making all in include
Making all in c2ffi
make[4]: Nothing to be done for 'all'.
make[4]: Nothing to be done for 'all-am'.
Making all in test
make[3]: Nothing to be done for 'all'.
  CXX      c2ffi-c2ffi.o
  CXX      c2ffi-init.o
  CXX      c2ffi-options.o
  CXX      c2ffi-OutputDriver.o
  CXX      c2ffi-Decl.o
  CXX      c2ffi-Type.o
  CXX      c2ffi-AST.o
  CXX      c2ffi-Expr.o
../../src/Expr.cpp:188:49: error: member reference type 'const clang::Preprocessor::MacroState' is not a pointer; did you mean to use '.'?
        const clang::MacroInfo *mi = (*i).second->getMacroInfo();
                                     ~~~~~~~~~~~^~
                                                .
../../src/Expr.cpp:188:51: error: no member named 'getMacroInfo' in 'clang::Preprocessor::MacroState'
        const clang::MacroInfo *mi = (*i).second->getMacroInfo();
                                     ~~~~~~~~~~~  ^
../../src/Expr.cpp:206:43: error: member reference type 'const clang::Preprocessor::MacroState' is not a pointer; did you mean to use '.'?
        clang::MacroInfo *mi = (*i).second->getMacroInfo();
                               ~~~~~~~~~~~^~
                                          .
../../src/Expr.cpp:206:45: error: no member named 'getMacroInfo' in 'clang::Preprocessor::MacroState'
        clang::MacroInfo *mi = (*i).second->getMacroInfo();
                               ~~~~~~~~~~~  ^
4 errors generated.
Makefile:654: recipe for target 'c2ffi-Expr.o' failed
make[3]: *** [c2ffi-Expr.o] Error 1
Makefile:736: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
Makefile:431: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
Makefile:362: recipe for target 'all' failed
make: *** [all] Error 2
mordocai:build/ (master) $ 

Macro defs not working

It should be possible also to get definitions as in #define, using "--with-macro-defs" but that's not the case.

Backport to llvm-3.5?

Hi, Ryan!

I'd really love to use C2FFI to make bindings for SDL2-GFX library.
However, I'm having a hard time building C2FFI.
The reason is, I'm on Debian Wheezy and it uses llvm-3.5 and clang-3.5 by default
-- hence I get plenty of build errors, at linking stage.

I've installed llvm-3.6 and clang-3.6 and even did update-alternatives, to make llvm-config
and clang point to 3.6 versions, however, I still get these build errors, apparently, I'm missing
some configuration.

So, do you know, what else needs to be done to properly use llvm 3.6 toolchain?
Either more update-alternatives commands (to make it default toolchain) or
some extra arguments to configure?

Or, perhaps, you could backport C2FFI to llvm 3.5 and clang 3.5 -- this way it should work
on Debian Wheezy out of the box?

I'm kind of frustrated now, because googling 'debian make llvm 3.6 the default' and the like
didn't give me any useful results...

Best regards,
Alex

nan handling

My math.h contains a definition for NAN as follows

#define NAN (0.0f/0.0f)

Which results in c2ffi json output as follows:

{ "tag": "const", "name": "NAN", "ns": 0, "location": "/usr/include/math.h:100:13", "type": { "tag": ":double", "bit-size": 64, "bit-alignment": 64 }, "value": nan }

Unfortunately, the JSON spec doesn't seem have NaN handling, so the above isn't legal JSON, which is making my parser barf.

I haven't a clue as to what the right 'fix' for this is as far as c2ffi is concerned.
No value? Some special sentinel value?

Thanks and thoughts appreciated.

c2ffi fails with an assert

i'm on debian stable, happens with both libbluetooth-dev 5.33-1 (testing) and 5.23-2+b1 (stable).

bluez.h:

#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>

tmp.h:

#include "bluez.h"
#include "macros.h"

first phase works as expected:

c2ffi bluez.h -M macros.h -A x86_64-pc-linux-gnu

second phase dies with assert:

c2ffi tmp.h -o delme -A x86_64-pc-linux-gnu
[...]
Skipping invalid Decl:
FunctionDecl 0x3273880 </usr/include/bluetooth/bluetooth.h:336:1, col:28> col:7 invalid bt_malloc 'void *(int)'
`-ParmVarDecl 0x32737c0 <col:17, col:24> col:24 invalid size 'int'
c2ffi: /media/store/work/llvm-3.6/include/llvm/ADT/PointerUnion.h:131: T llvm::PointerUnion<const clang::ValueDecl *, const clang::Expr *>::get() const [PT1 = const clang::ValueDecl *, PT2 = const clang::Expr *, T = const clang::Expr *]: Assertion `is<T>() && "Invalid accessor called"' failed.
Aborted

when run in gdb the backtrace is:

[...]
Skipping invalid Decl:
FunctionDecl 0x2493880 </usr/include/bluetooth/bluetooth.h:336:1, col:28> col:7 invalid bt_malloc 'void *(int)'
`-ParmVarDecl 0x24937c0 <col:17, col:24> col:24 invalid size 'int'
c2ffi: /media/store/work/llvm-3.6/include/llvm/ADT/PointerUnion.h:131: T llvm::PointerUnion<const clang::ValueDecl *, const clang::Expr *>::get() const [PT1 = const clang::ValueDecl *, PT2 = const clang::Expr *, T = const clang::Expr *]: Assertion `is<T>() && "Invalid accessor called"' failed.

Program received signal SIGABRT, Aborted.
0x00007ffff67bb107 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56  ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) backtrace
#0  0x00007ffff67bb107 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007ffff67bc4e8 in __GI_abort () at abort.c:89
#2  0x00007ffff67b4226 in __assert_fail_base (fmt=0x7ffff68eace8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x1393768 "is<T>() && \"Invalid accessor called\"", 
    file=file@entry=0x139378d "/media/store/work/llvm-3.6/include/llvm/ADT/PointerUnion.h", line=line@entry=131, 
    function=function@entry=0x13937c8 "T llvm::PointerUnion<const clang::ValueDecl *, const clang::Expr *>::get() const [PT1 = const clang::ValueDecl *, PT2 = const clang::Expr *, T = const clang::Expr *]")
    at assert.c:92
#3  0x00007ffff67b42d2 in __GI___assert_fail (assertion=0x1393768 "is<T>() && \"Invalid accessor called\"", file=0x139378d "/media/store/work/llvm-3.6/include/llvm/ADT/PointerUnion.h", line=131, 
    function=0x13937c8 "T llvm::PointerUnion<const clang::ValueDecl *, const clang::Expr *>::get() const [PT1 = const clang::ValueDecl *, PT2 = const clang::Expr *, T = const clang::Expr *]") at assert.c:101
#4  0x0000000000410752 in get<clang::Expr const*> (this=<optimized out>) at /media/store/work/llvm-3.6/include/llvm/ADT/PointerUnion.h:131
#5  c2ffi::C2FFIASTConsumer::make_decl (this=<optimized out>, d=<optimized out>, is_toplevel=<optimized out>) at AST.cpp:224
#6  0x000000000040fc10 in c2ffi::C2FFIASTConsumer::HandleDecl (this=0x22b76d0, d=0x269de50, ns=<optimized out>) at AST.cpp:101
#7  0x00000000004121fd in c2ffi::C2FFIASTConsumer::HandleTopLevelDecl (this=0x22b76d0, d=...) at AST.cpp:145
#8  0x000000000078d2ac in clang::ParseAST(clang::Sema&, bool, bool) ()
#9  0x000000000078d062 in clang::ParseAST(clang::Preprocessor&, clang::ASTConsumer*, clang::ASTContext&, bool, clang::TranslationUnitKind, clang::CodeCompleteConsumer*, bool) ()
#10 0x00000000004084ea in main (argc=<optimized out>, argv=<optimized out>) at c2ffi.cpp:94

if i run c2ffi only on macros.h (i.e. not on tmp.h) then it fails with a different assert:

[...]
macros.h:9703:45: error: expected expression
const long __c2ffi___need_NULL = __need_NULL;
                                            ^
c2ffi: /media/store/work/llvm/tools/clang/lib/Sema/Sema.cpp:249: clang::Sema::~Sema(): Assertion `DelayedTypos.empty() && "Uncorrected typos!"' failed.

Program received signal SIGABRT, Aborted.
0x00007ffff67bb107 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56  ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) backtrace
#0  0x00007ffff67bb107 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007ffff67bc4e8 in __GI_abort () at abort.c:89
#2  0x00007ffff67b4226 in __assert_fail_base (fmt=0x7ffff68eace8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x14ea360 "DelayedTypos.empty() && \"Uncorrected typos!\"", 
    file=file@entry=0x14ea328 "/media/store/work/llvm/tools/clang/lib/Sema/Sema.cpp", line=line@entry=249, function=function@entry=0x14ee2d0 <clang::Sema::~Sema()::__PRETTY_FUNCTION__> "clang::Sema::~Sema()")
    at assert.c:92
#3  0x00007ffff67b42d2 in __GI___assert_fail (assertion=0x14ea360 "DelayedTypos.empty() && \"Uncorrected typos!\"", file=0x14ea328 "/media/store/work/llvm/tools/clang/lib/Sema/Sema.cpp", line=249, 
    function=0x14ee2d0 <clang::Sema::~Sema()::__PRETTY_FUNCTION__> "clang::Sema::~Sema()") at assert.c:101
#4  0x000000000084bd9b in clang::Sema::~Sema() ()
#5  0x000000000043829c in std::default_delete<clang::Sema>::operator()(clang::Sema*) const ()
#6  0x0000000000432c27 in std::unique_ptr<clang::Sema, std::default_delete<clang::Sema> >::~unique_ptr() ()
#7  0x000000000078d07a in clang::ParseAST(clang::Preprocessor&, clang::ASTConsumer*, clang::ASTContext&, bool, clang::TranslationUnitKind, clang::CodeCompleteConsumer*, bool) ()
#8  0x00000000004084ea in main (argc=<optimized out>, argv=<optimized out>) at c2ffi.cpp:94
(gdb) 

c2ffi seems to be statically linked to llvm:

$ ldd /home/alendvai/workspace/c2ffi/src/c2ffi
    linux-vdso.so.1 (0x00007ffc49fb3000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fb9350a2000)
    libncurses.so.5 => /lib/x86_64-linux-gnu/libncurses.so.5 (0x00007fb934e7d000)
    libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007fb934c53000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fb934a38000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fb93472d000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb93442c000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fb934216000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fb933ff9000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb933c50000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fb9352a6000)

this is how i compiled c2ffi:

PATH=/media/store/work/llvm-3.6/bin/:$PATH; LDFLAGS=/media/store/work/llvm-3.6/lib/; ./configure --enable-debug
PATH=/media/store/work/llvm-3.6/bin/:$PATH make -j2

llvm version:

$ svn info
Path: .
Working Copy Root Path: /media/store/work/llvm
URL: http://llvm.org/svn/llvm-project/llvm/branches/release_36
Relative URL: ^/llvm/branches/release_36
Repository Root: http://llvm.org/svn/llvm-project
Repository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8
Revision: 251109
Node Kind: directory
Schedule: normal
Last Changed Author: hans
Last Changed Rev: 240577
Last Changed Date: 2015-06-24 21:50:28 +0200 (Wed, 24 Jun 2015)

configure: fix checking for setupterm in -lcurses

I was getting this error on Slackware:

checking for setupterm in -lcurses... no
checking for setupterm in -lncurses... no
configure: error: curses not found

A quick fix that worked for me is to check terminfo library:

diff --git a/configure.ac b/configure.ac
index 8eec8d9..eb9c61d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,7 +33,8 @@ AC_CHECK_LIB(c, dlopen, [],
     AC_MSG_ERROR([dlopen not found])))
 AC_CHECK_LIB(curses, setupterm, LIBCURSES="-lcurses",
   AC_CHECK_LIB(ncurses, setupterm, LIBCURSES="-lncurses",
-    AC_MSG_ERROR([curses not found])))
+    AC_CHECK_LIB(tinfo, setupterm, LIBCURSES="-ltinfo",
+      AC_MSG_ERROR([curses not found]))))
 AC_CHECK_LIB(z, compress, LIBZ="-lz", AC_MSG_ERROR([-lz not found]))

 AC_SUBST(LIBDL)

Might be relevant: http://llvm.org/klaus/llvm/commit/8d8bdff6d7eccb05bf16e18141263ee72ea8296b/

Order of C macros in the output

it would be nice if the macros came out in a stable order, so that line diff becomes meaningful between re-runs.

not an urgent issue, it's more of a feature request.

Weird error compiling via docker

I'd like to contribute a Dockerfile for c2ffi, but I have trouble compiling. I use the attached Docker file (still a bit messy, I'm in the middle of trying different things) and I get this error during linking:

/usr/bin/ld: /usr/lib/llvm-3.7/bin/../lib/libclangAST.a(DeclCXX.o): undefined reference to symbol '_ZN4llvm19SmallPtrSetImplBase16shrink_and_clearEv'
//usr/lib/x86_64-linux-gnu/libLLVM-3.7.so.1: error adding symbols: DSO missing from command line
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I've tried several different approaches, but I always get stuck. As you can see, I didn't compile LLVM and clang, but I used the packages from LLVM to install version 3.7.1 specifically from http://llvm.org/apt/
Dockerfile.txt

./autogen fails due to syntax erros in gen-functions

I don't know about shell scripts but from TLDP it appears one can't use bother function and () when defining a function.

Removing the function keyword from every function definition allowed ./autogen to run with no problems.

Also the configure script fail to catch that I needed libclang-dev (or clang) so make failed until I installed it. This is against the 3.4 branch

Hope it helps

Function typedefs drop type information

Hello again. I am generating a spec from some raspbian headers. This header line:
typedef void VCHI_MESSAGE_DRIVER_EVENT_CALLBACK_T( void *state );
is translated to:
{ "tag": "typedef", "ns": 0, "name": "VCHI_MESSAGE_DRIVER_EVENT_CALLBACK_T", "location": "raspbian/usr/include/interface/vchi/message_drivers/message.h:156:14", "type": { "tag": ":function" } }
losing the void return type as well as the (void* state) parameter entirely.
I am using up-to-date 4.0 LLVM/CLANG this time:)

Any thoughts?

requires -ledit

not just llvm. needs a documentation.
ubuntu 16.04, llvm-3.7

char16_t* parameter type gets replaced with int*

This way strings become integers :)

Another thing is the representation of two-word types, which are written as :unsigned-int, :unsigned-char etc. Is there a special reason for not using the original type name?

Meaning of NS

Again, from the "doing fancy things with c2ffi" dept...

Types defined inside typedefs are sometimes translated into similar deep JSON structures, and other times, into separate and anonymous (non zero ID and non-zero NS?) definitions of the inner type followed by typedef definition referring to them by id.

  • Could you shed some light on the meaning of NS values? As far as I can tell, anything non-zero means that a non-global scope is active, but the numeric values seem to be never referred to.

  • IDs seem to be used by anonymous definitions and typedefs, but sometimes objects are assigned an ID even though there is a NAME present. Is that the case only for inner definitions?

  • IDs seem to be unique, except when they are 0. There are a lot of entities with ID 0. This makes IDs not particularly useful in say, enumerating entities.

make error

Hey
I cant seem to build c2ffi with clang 5.0

>:~/Desktop/ruby/c2ffi/build$ cmake ..
-- Found LLVM 5.0.2
-- LLVM installed in /usr/lib/llvm-5.0
-- Using LLVMConfig.cmake in: /usr/lib/llvm-5.0/cmake
-- Using llvm libs: LLVMCore;LLVMSupport;LLVMMCParser;LLVMOption;LLVMBitReader;LLVMProfileData
-- CMAKE_CXX_FLAGS:  -std=c++11 -fno-exceptions -fno-rtti
-- CMAKE_EXE_LINKER_FLAGS: 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/arjun/Desktop/ruby/c2ffi/build

>:~/Desktop/ruby/c2ffi/build$ make
Scanning dependencies of target c2ffi
[  7%] Building CXX object CMakeFiles/c2ffi.dir/src/Expr.cpp.o
/home/arjun/Desktop/ruby/c2ffi/src/Expr.cpp:22:29: fatal error: clang/Lex/Token.h: No such file or directory
compilation terminated.
CMakeFiles/c2ffi.dir/build.make:62: recipe for target 'CMakeFiles/c2ffi.dir/src/Expr.cpp.o' failed
make[2]: *** [CMakeFiles/c2ffi.dir/src/Expr.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/c2ffi.dir/all' failed
make[1]: *** [CMakeFiles/c2ffi.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

I installed clang5.0 using this guide - https://askubuntu.com/questions/905205/installing-clang-5-0-and-using-c17

>$ dpkg -l llvm*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                 Version                 Architecture            Description
+++-====================================-=======================-=======================-==============================================================================
un  llvm                                 <none>                  <none>                  (no description available)
un  llvm-3.8-dev                         <none>                  <none>                  (no description available)
ii  llvm-5.0                             1:5.0.2~svn328729-1~exp amd64                   Modular compiler and toolchain technologies
ii  llvm-5.0-dev                         1:5.0.2~svn328729-1~exp amd64                   Modular compiler and toolchain technologies, libraries and headers
un  llvm-5.0-doc                         <none>                  <none>                  (no description available)
ii  llvm-5.0-runtime                     1:5.0.2~svn328729-1~exp amd64                   Modular compiler and toolchain technologies, IR interpreter

I am on elementary os 0.4/ubuntu 16.04 build

c2ffi dies when used on SDL2_gfxPrimitives.h

Hi, Ryan!

I'm trying now to generate bindings for SDL2_gfx.
My header file looks like

#include <SDL2/SDL2_gfxPrimitives.h>

and the command I use to generate bindings is

~/quicklisp/local-projects/c2ffi/build/src/c2ffi SDL2_gfx.h -M macros.h -A x86_64-pc-linux-gnu > 1.txt

There's a lot of normal JSON output, which does to 1.txt
and then it fails with an assertion

c2ffi: /home/popolit/llvm/tools/clang/lib/AST/RecordLayoutBuilder.cpp:2806: const clang::ASTRecordLayout &clang::ASTContext::getASTRecordLayout(const clang::RecordDecl *) const: Assertion `D && "Cannot get layout of forward declarations!"' failed.
Aborted

Honestly, I've no clue where to go from here and how to diagnose it. Would be happy to hear any suggestions.

Best regards,
Alex

failed assert/segfault when using -M

i'm on a debian testing, using clang HEAD.

if i compile clang with asserts enabled, then c2ffi errors out on a failed assert.

   ~/workspace/c2ffi/src/c2ffi -o libgcrypt.c2ffi-spec -M /tmp/macros.h /usr/include/gcrypt.h

if i compile clang without asserts, then it segfaults (yay C).

i assume it's just a transient clang issue.

the c2ffi doc says that i should use clang v3.3, but there's no such tag yet. i assume it's the upcoming release... which clang version shall i use?

my c2ffi: 06c8695
my clang: 177222

c2ffi C++ parsing issues.

Current issues

  • Parsing _builtin*

Fixed issues

Segfaults

(This should be fixed by 251e989.)

From #11, parsing OutputDriver.cpp from c2ffi source will segfault, e.g.,

$ ./src/c2ffi ../src/OutputDriver.cpp -i ../src/include/ -i /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/x86_64-pc-linux-gnu -i /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/
<output>
segmentation fault
$

This appears to be happening in the template handling code.

default system include path list is not populated

AFAIU, when c2ffi invokes the LLVM C parser code through the LLVM API, then it needs to give a full list of include search paths. when using c2ffi with an LLVM that has not been installed into the default install-prefix, then the standard headers are not found (e.g. stdbool.h).

this seems to be a kludge in LLVM itself, but i open this issue to be able to track this.

see e.g. the FIXME comment in http://clang.llvm.org/doxygen/InitHeaderSearch_8cpp_source.html at line 351 (AddDefaultCPlusPlusIncludePaths).

No const information available

example:

//test.h
char x(char* c);
const char y(const char* c);

both functions return the same types

[
{ "tag": "function", "name": "x", "ns": 0, "location": "test.h:2:6", "variadic": false, "inline": false, "storage-class": "none", "parameters": [{ "tag": "parameter", "name": "c", "type": { "tag": ":pointer", "type": { "tag": ":char", "bit-size": 8, "bit-alignment": 8 } } }], "return-type": { "tag": ":char", "bit-size": 8, "bit-alignment": 8 } },
{ "tag": "function", "name": "y", "ns": 0, "location": "test.h:3:12", "variadic": false, "inline": false, "storage-class": "none", "parameters": [{ "tag": "parameter", "name": "c", "type": { "tag": ":pointer", "type": { "tag": ":char", "bit-size": 8, "bit-alignment": 8 } } }], "return-type": { "tag": ":char", "bit-size": 8, "bit-alignment": 8 } }
]

make install does nothing

Hi, I made a c2ffi AUR PKGBUILD recipe for Arch Linux (link) and I had to install the binary "manually" (so to speak) to /usr/bin because, following the building instructions here, doing a make install does ... nothing. Is there anything I missed, or is make install currently a noop? (BTW, I'm not good at cmake stuff, otherwise I would have patched the relevant file(s) already).

c2ffi can't find header file 'stddef.h'

Just stumbled over this:

//----[file case.h]-----------------------

include <fluidsynth.h>

// ----[end] --------------------------------

Then, running c2ffi:

ralf@flaptop:/tmp$ c2ffi case.h 1>/dev/null
In file included from case.h:2:
In file included from /usr/local/include/fluidsynth.h:24:
/usr/include/stdio.h:33:11: fatal error: 'stddef.h' file not found

include <stddef.h>

      ^

c2ffi: RecordLayoutBuilder.cpp:2356: const clang::ASTRecordLayout
&clang::ASTContext::getASTRecordLayout(const clang::RecordDecl *) const: Assertion `!D->isInvalidDecl() && "Cannot get layout of invalid decl!"' failed.
Stack dump:

  1. /usr/include/libio.h:316:1: current parser token 'typedef'
    Aborted

??? But this runs without problems:

ralf@flaptop:/tmp$ clang -E case.h 1>/dev/null

No error here.
What am I doing wrong?

TIA RalfD

Enums always get id=0

Example input:

enum Enum1 { A, B, C };
enum Enum2 { D, E };

class Class1
{
enum Enum3 { F, G, H };
};

Output:

[
{ "tag": "enum", "ns": 0, "name": "Enum1", "id": 0, "location": "enum_test.h:1:6", "fields": [{ "tag": "field", "name": "A", "value": 0 }, { "tag": "field", "name": "B", "value": 1 }, { "tag": "field", "name": "C", "value": 2 }] },
{ "tag": "enum", "ns": 0, "name": "Enum2", "id": 0, "location": "enum_test.h:2:6", "fields": [{ "tag": "field", "name": "D", "value": 0 }, { "tag": "field", "name": "E", "value": 1 }] },
{ "tag": "class", "ns": 0, "name": "Class1", "id": 1, "location": "enum_test.h:4:7", "bit-size": 8, "bit-alignment": 8, "parents": [], "fields": [], "methods": [] },
{ "tag": "enum", "ns": 1, "name": "Enum3", "id": 0, "location": "enum_test.h:6:6", "fields": [{ "tag": "field", "name": "F", "value": 0 }, { "tag": "field", "name": "G", "value": 1 }, { "tag": "field", "name": "H", "value": 2 }] }
]

using llvm 3.5

emitted json wrong for typedef'd inline anonymous enum?

shouldn't the inline anonymous enum be in the typedef's type under the tag "enum", symmetrically with struct's?

input:

typedef enum
{
    SDL_FALSE = 0,
    SDL_TRUE = 1
} SDL_bool;

output:

  {
    "fields": [
      {
        "value": 0,
        "name": "SDL_FALSE",
        "tag": "field"
      },
      {
        "value": 1,
        "name": "SDL_TRUE",
        "tag": "field"
      }
    ],
    "location": "\/usr\/include\/SDL2\/SDL_stdinc.h:116:9",
    "id": 45,
    "name": "",
    "ns": 0,
    "tag": "enum"
  },
  {
    "type": {
      "id": 45,
      "name": "",
      "tag": ":enum"
    },
    "location": "\/usr\/include\/SDL2\/SDL_stdinc.h:120:3",
    "name": "SDL_bool",
    "ns": 0,
    "tag": "typedef"
  }
]```

Tracking down why things don't get listed in the output files

I'm currently wrapping glib, and I'm feeling rather naked, while trying to track down the causes of absence of certain macro definitions from the spec files.

Exhibit one -- I'm looking for the macro called "TRUE", which
is defined in /usr/include/glib-2.0/glib/gmacros.h:

#ifndef FALSE
#define FALSE   (0)
#endif

#ifndef TRUE
#define TRUE    (!FALSE)
#endif

Here's the files

glib-raw.h:

#include <glib.h>

glib-raw.lisp:

(cl:defpackage :glib-raw
  (:use :autowrap))

(cl:in-package :glib-raw)

(cl:eval-when (:compile-toplevel :load-toplevel :execute)
  (cffi-sys:%load-foreign-library
   :libclutter "/usr/lib64/libglib-2.0.so"))

(autowrap:c-include (cl:namestring (asdf:system-relative-pathname (asdf:find-system :cffi-clutter)
                                                                  "glib-raw.h"))
                    :exclude-arch ("i686-pc-linux-gnu"
                                   "i686-pc-win32"
                                   "x86_64-pc-win64"
                                   "i686-apple-darwin9"
                                   "x86_64-apple-darwin9")
                    :exclude-sources ("/usr/local/lib/clang/3.3/include/(?!stddef.h).*"
                                      "/usr/include/(?:getopt|pthread|sched|stdio|time|unistd|xlocale).h"
                                      "/usr/include/glib-2.0/glib/deprecated")
                    :exclude-definitions ("signal")
                    :sysincludes '("/usr/include/"
                                   "/usr/include/linux"
                                   "/usr/lib/clang/3.3/include/"
                                   "/usr/include/glib-2.0"
                                   "/usr/lib64/glib-2.0/include")
                    :exclude-constants (".*")
                    :constant-accessor const)

Here's the output of the wrapping process (note both of the c2ffi command lines included):

; compiling (C-INCLUDE (COMMON-LISP:NAMESTRING #) ...)
; c2ffi /home/deepfire/src/cffi-clutter/glib-raw.h -o /home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.spec -M /home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h -A x86_64-pc-linux-gnu -i /usr/include/ -i /usr/include/linux -i /usr/lib/clang/3.3/include/ -i /usr/include/glib-2.0 -i /usr/lib64/glib-2.0/include
In file included from /home/deepfire/src/cffi-clutter/glib-raw.h:1:
In file included from /usr/include/glib-2.0/glib.h:32:
In file included from /usr/include/glib-2.0/glib/galloca.h:34:
In file included from /usr/include/glib-2.0/glib/gtypes.h:37:
/usr/include/time.h:205:8: error: unknown type name 'size_t'; did you mean 'time_t'?
extern size_t strftime (char *__restrict __s, size_t __maxsize,
       ^
/usr/include/time.h:75:18: note: 'time_t' declared here
typedef __time_t time_t;
                 ^
/usr/include/time.h:205:47: error: unknown type name 'size_t'; did you mean 'time_t'?
extern size_t strftime (char *__restrict __s, size_t __maxsize,
                                              ^
/usr/include/time.h:75:18: note: 'time_t' declared here
typedef __time_t time_t;
                 ^
/usr/include/time.h:223:8: error: unknown type name 'size_t'; did you mean 'time_t'?
extern size_t strftime_l (char *__restrict __s, size_t __maxsize,
       ^
/usr/include/time.h:75:18: note: 'time_t' declared here
typedef __time_t time_t;
                 ^
/usr/include/time.h:223:49: error: unknown type name 'size_t'; did you mean 'time_t'?
extern size_t strftime_l (char *__restrict __s, size_t __maxsize,
                                                ^
/usr/include/time.h:75:18: note: 'time_t' declared here
typedef __time_t time_t;
                 ^
In file included from /home/deepfire/src/cffi-clutter/glib-raw.h:1:
In file included from /usr/include/glib-2.0/glib.h:36:
In file included from /usr/include/glib-2.0/glib/gbacktrace.h:35:
In file included from /usr/include/signal.h:357:
/usr/include/bits/sigstack.h:53:5: error: unknown type name 'size_t'
    size_t ss_size;
    ^
In file included from /home/deepfire/src/cffi-clutter/glib-raw.h:1:
In file included from /usr/include/glib-2.0/glib.h:109:
In file included from /usr/include/glib-2.0/glib/deprecated/gthread.h:123:
In file included from /usr/include/pthread.h:23:
In file included from /usr/include/sched.h:42:
/usr/include/bits/sched.h:204:30: error: unknown type name 'size_t'
extern int __sched_cpucount (size_t __setsize, const cpu_set_t *__setp)
                             ^
/usr/include/bits/sched.h:206:37: error: unknown type name 'size_t'
extern cpu_set_t *__sched_cpualloc (size_t __count) __THROW __wur;
                                    ^
In file included from /home/deepfire/src/cffi-clutter/glib-raw.h:1:
In file included from /usr/include/glib-2.0/glib.h:109:
In file included from /usr/include/glib-2.0/glib/deprecated/gthread.h:123:
/usr/include/pthread.h:305:11: error: unknown type name 'size_t'
                                      size_t *__guardsize)
                                      ^
/usr/include/pthread.h:310:11: error: unknown type name 'size_t'
                                      size_t __guardsize)
                                      ^
/usr/include/pthread.h:368:19: error: unknown type name 'size_t'
                                      __attr, size_t *__restrict __stacksize)
                                              ^
/usr/include/pthread.h:375:11: error: unknown type name 'size_t'
                                      size_t __stacksize)
                                      ^
/usr/include/pthread.h:382:7: error: unknown type name 'size_t'
                                  size_t *__restrict __stacksize)
                                  ^
/usr/include/pthread.h:389:7: error: unknown type name 'size_t'
                                  size_t __stacksize) __THROW __nonnull ((1));
                                  ^
; c2ffi /home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h -o /home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.macro.spec -A x86_64-pc-linux-gnu -i /usr/include/ -i /usr/include/linux -i /usr/lib/clang/3.3/include/ -i /usr/include/glib-2.0 -i /usr/lib64/glib-2.0/include
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1104:46: warning: implicit declaration of function 'G_GINT64_CONSTANT' is invalid in C99
const long __c2ffi_G_TIME_SPAN_MILLISECOND = G_TIME_SPAN_MILLISECOND;
                                             ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:8:34: note: expanded from macro 'G_TIME_SPAN_MILLISECOND'
#define G_TIME_SPAN_MILLISECOND (G_GINT64_CONSTANT (1000))
                                 ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1104:46: error: initializer element is not a compile-time constant
const long __c2ffi_G_TIME_SPAN_MILLISECOND = G_TIME_SPAN_MILLISECOND;
                                             ^~~~~~~~~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:8:33: note: expanded from macro 'G_TIME_SPAN_MILLISECOND'
#define G_TIME_SPAN_MILLISECOND (G_GINT64_CONSTANT (1000))
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1106:41: error: initializer element is not a compile-time constant
const long __c2ffi_G_TIME_SPAN_SECOND = G_TIME_SPAN_SECOND;
                                        ^~~~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:14:28: note: expanded from macro 'G_TIME_SPAN_SECOND'
#define G_TIME_SPAN_SECOND (G_GINT64_CONSTANT (1000000))
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1114:38: error: initializer element is not a compile-time constant
const long __c2ffi_G_TIME_SPAN_DAY = G_TIME_SPAN_DAY;
                                     ^~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:38:25: note: expanded from macro 'G_TIME_SPAN_DAY'
#define G_TIME_SPAN_DAY (G_GINT64_CONSTANT (86400000000))
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1115:41: error: initializer element is not a compile-time constant
const long __c2ffi_G_TIME_SPAN_MINUTE = G_TIME_SPAN_MINUTE;
                                        ^~~~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:41:28: note: expanded from macro 'G_TIME_SPAN_MINUTE'
#define G_TIME_SPAN_MINUTE (G_GINT64_CONSTANT (60000000))
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1119:39: error: initializer element is not a compile-time constant
const long __c2ffi_G_TIME_SPAN_HOUR = G_TIME_SPAN_HOUR;
                                      ^~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:53:26: note: expanded from macro 'G_TIME_SPAN_HOUR'
#define G_TIME_SPAN_HOUR (G_GINT64_CONSTANT (3600000000))
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1157:47: error: use of undeclared identifier 'LLONG_MAX'
const unsigned long long __c2ffi_ULLONG_MAX = ULLONG_MAX;
                                              ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:167:21: note: expanded from macro 'ULLONG_MAX'
#define ULLONG_MAX (LLONG_MAX * 2ULL + 1)
                    ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1160:32: error: use of undeclared identifier 'LLONG_MAX'
const long __c2ffi_LLONG_MIN = LLONG_MIN;
                               ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:176:21: note: expanded from macro 'LLONG_MIN'
#define LLONG_MIN (-LLONG_MAX-1)
                    ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1268:33: error: use of undeclared identifier '__cpu_mask'
const long __c2ffi___NCPUBITS = __NCPUBITS;
                                ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:500:33: note: expanded from macro '__NCPUBITS'
#define __NCPUBITS (8 * sizeof (__cpu_mask))
                                ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1272:32: error: expected ';' after top level declarator
const char* __c2ffi_G_STRLOC = G_STRLOC;
                               ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:512:31: note: expanded from macro 'G_STRLOC'
#define G_STRLOC __FILE__ ":" G_STRINGIFY (__LINE__)
                              ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1287:40: warning: implicit declaration of function 'G_ENCODE_VERSION' is invalid in C99
const long __c2ffi_GLIB_VERSION_2_36 = GLIB_VERSION_2_36;
                                       ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:557:28: note: expanded from macro 'GLIB_VERSION_2_36'
#define GLIB_VERSION_2_36 (G_ENCODE_VERSION (2, 36))
                           ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1287:40: error: initializer element is not a compile-time constant
const long __c2ffi_GLIB_VERSION_2_36 = GLIB_VERSION_2_36;
                                       ^~~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:557:27: note: expanded from macro 'GLIB_VERSION_2_36'
#define GLIB_VERSION_2_36 (G_ENCODE_VERSION (2, 36))
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1288:40: error: initializer element is not a compile-time constant
const long __c2ffi_GLIB_VERSION_2_34 = GLIB_VERSION_2_34;
                                       ^~~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:560:27: note: expanded from macro 'GLIB_VERSION_2_34'
#define GLIB_VERSION_2_34 (G_ENCODE_VERSION (2, 34))
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1289:40: error: initializer element is not a compile-time constant
const long __c2ffi_GLIB_VERSION_2_32 = GLIB_VERSION_2_32;
                                       ^~~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:563:27: note: expanded from macro 'GLIB_VERSION_2_32'
#define GLIB_VERSION_2_32 (G_ENCODE_VERSION (2, 32))
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1290:40: error: initializer element is not a compile-time constant
const long __c2ffi_GLIB_VERSION_2_30 = GLIB_VERSION_2_30;
                                       ^~~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:566:27: note: expanded from macro 'GLIB_VERSION_2_30'
#define GLIB_VERSION_2_30 (G_ENCODE_VERSION (2, 30))
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1297:40: error: initializer element is not a compile-time constant
const long __c2ffi_GLIB_VERSION_2_28 = GLIB_VERSION_2_28;
                                       ^~~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:587:27: note: expanded from macro 'GLIB_VERSION_2_28'
#define GLIB_VERSION_2_28 (G_ENCODE_VERSION (2, 28))
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1298:40: error: initializer element is not a compile-time constant
const long __c2ffi_GLIB_VERSION_2_26 = GLIB_VERSION_2_26;
                                       ^~~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:590:27: note: expanded from macro 'GLIB_VERSION_2_26'
#define GLIB_VERSION_2_26 (G_ENCODE_VERSION (2, 26))
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1343:30: error: use of undeclared identifier '__sighandler_t'
const long __c2ffi_SIG_IGN = SIG_IGN;
                             ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:725:19: note: expanded from macro 'SIG_IGN'
#define SIG_IGN ((__sighandler_t) 1)
                  ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1348:30: error: use of undeclared identifier '__sighandler_t'
const long __c2ffi_SIG_ERR = SIG_ERR;
                             ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:740:19: note: expanded from macro 'SIG_ERR'
#define SIG_ERR ((__sighandler_t) -1)
                  ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1349:30: error: use of undeclared identifier '__sighandler_t'
const long __c2ffi_SIG_DFL = SIG_DFL;
                             ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:743:19: note: expanded from macro 'SIG_DFL'
#define SIG_DFL ((__sighandler_t) 0)
                  ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1384:32: error: use of undeclared identifier 'gint8'
const long __c2ffi_G_MININT8 = G_MININT8;
                               ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:848:21: note: expanded from macro 'G_MININT8'
#define G_MININT8 ((gint8) 0x80)
                    ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1385:32: error: use of undeclared identifier 'gint8'
const long __c2ffi_G_MAXINT8 = G_MAXINT8;
                               ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:851:21: note: expanded from macro 'G_MAXINT8'
#define G_MAXINT8 ((gint8) 0x7f)
                    ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1386:33: error: use of undeclared identifier 'guint8'
const long __c2ffi_G_MAXUINT8 = G_MAXUINT8;
                                ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:854:22: note: expanded from macro 'G_MAXUINT8'
#define G_MAXUINT8 ((guint8) 0xff)
                     ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1387:33: error: use of undeclared identifier 'gint16'
const long __c2ffi_G_MININT16 = G_MININT16;
                                ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:857:22: note: expanded from macro 'G_MININT16'
#define G_MININT16 ((gint16) 0x8000)
                     ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1388:33: error: use of undeclared identifier 'gint16'
const long __c2ffi_G_MAXINT16 = G_MAXINT16;
                                ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:860:22: note: expanded from macro 'G_MAXINT16'
#define G_MAXINT16 ((gint16) 0x7fff)
                     ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1391:34: error: use of undeclared identifier 'guint16'
const long __c2ffi_G_MAXUINT16 = G_MAXUINT16;
                                 ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:869:23: note: expanded from macro 'G_MAXUINT16'
#define G_MAXUINT16 ((guint16) 0xffff)
                      ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1392:33: error: use of undeclared identifier 'gint32'
const long __c2ffi_G_MININT32 = G_MININT32;
                                ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:872:22: note: expanded from macro 'G_MININT32'
#define G_MININT32 ((gint32) 0x80000000)
                     ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1393:33: error: use of undeclared identifier 'gint32'
const long __c2ffi_G_MAXINT32 = G_MAXINT32;
                                ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:875:22: note: expanded from macro 'G_MAXINT32'
#define G_MAXINT32 ((gint32) 0x7fffffff)
                     ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1394:43: error: initializer element is not a compile-time constant
const unsigned long __c2ffi_G_MAXUINT64 = G_MAXUINT64;
                                          ^~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:878:21: note: expanded from macro 'G_MAXUINT64'
#define G_MAXUINT64 G_GINT64_CONSTANT(0xffffffffffffffffU)
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1395:34: error: use of undeclared identifier 'guint32'
const long __c2ffi_G_MAXUINT32 = G_MAXUINT32;
                                 ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:881:23: note: expanded from macro 'G_MAXUINT32'
#define G_MAXUINT32 ((guint32) 0xffffffff)
                      ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1411:33: error: use of undeclared identifier 'gint64'
const long __c2ffi_G_MININT64 = G_MININT64;
                                ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:929:22: note: expanded from macro 'G_MININT64'
#define G_MININT64 ((gint64) G_GINT64_CONSTANT(0x8000000000000000))
                     ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1435:33: error: initializer element is not a compile-time constant
const long __c2ffi_G_MAXINT64 = G_MAXINT64;
                                ^~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1001:20: note: expanded from macro 'G_MAXINT64'
#define G_MAXINT64 G_GINT64_CONSTANT(0x7fffffffffffffff)
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1463:35: error: use of undeclared identifier 'gchar'; did you mean 'char'?
const long __c2ffi_G_LOG_DOMAIN = G_LOG_DOMAIN;
                                  ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1085:24: note: expanded from macro 'G_LOG_DOMAIN'
#define G_LOG_DOMAIN ((gchar*) 0)
                       ^
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1463:35: error: expected expression
/home/deepfire/src/cffi-clutter/glib-raw.x86_64-pc-linux-gnu.h:1085:30: note: expanded from macro 'G_LOG_DOMAIN'
#define G_LOG_DOMAIN ((gchar*) 0)
                             ^

Here's the absence of anything TRUE:

[deepfire@betelheise cffi-clutter]$ grep TRUE glib-raw.x86_64-pc-linux-gnu.macro.spec
[deepfire@betelheise cffi-clutter]$

LLVM 3.8

c2ffi seems to build with LLVM 3.8 (strangely linking code compiled with 3.7 does not quite work). Could you please verify this works and maybe update documentation/CMakeLists.txt.

false success return code from c2ffi

$ /home/alendvai/workspace/c2ffi/src/c2ffi /home/alendvai/common-lisp/hu.dwim.mosquitto/autospec/mosquitto-spec.h -D null -M /tmp/tmpP3BI68WS.tmp -A x86_64-pc-linux-gnu -i /usr/include/linux/
/home/alendvai/common-lisp/hu.dwim.mosquitto/autospec/mosquitto-spec.h:1:10: fatal error: 'mosquitto.h' file not found
#include <mosquitto.h>
         ^
$ echo $?
0

Add include tags

If a file incldues another file, it would be helpful, to add a list tagged with "include" so a #include "file.h" could be converted to <mylang_include> "file.mylang" (and maybe even an option not to include files specified by #include, but I'm not sure, if this is possible, but since the location is given, it's not too difficult not to include unwanted files and recreate similar file partition as in original)

clang 3.7

Can't build. Error in Expr.cpp on line 187;

../../src/Expr.cpp:187:49: error: member reference type 'const clang::Preprocessor::MacroState' is not a pointer; did you mean to use '.'? const clang::MacroInfo *mi = (*i).second->getMacroInfo(); ~~~~~~~~~~~^~ . ../../src/Expr.cpp:187:51: error: no member named 'getMacroInfo' in 'clang::Preprocessor::MacroState' const clang::MacroInfo *mi = (*i).second->getMacroInfo();

Building on ArchLinux using clang-3.7.

inline output of inline types

the situation

in C you can have this:

typedef enum {
  a = 0,
  b
} typeName;

this is a C typedef with an inline definition of an anonymous enum. in the c2ffi json output it currently shows up as two separate entries, connected by the ID of the anonymous entry.

the headache

cffi/c2ffi has a means to filter out definitions, and it would complicate the code that it needs to deal with the reconnection of these two json entries. the current kludge is to always emit every anonymous entry with a generated name.

proposed solution

would it be possible for the json output to have the same structure as the C typedef, i.e. the anonymous type declaration to be nested inside the type field of the typedef json entry?

references

the cffi issue: cffi/cffi#107
cffi-dev mail (cffi needs patching to support this): https://mailman.common-lisp.net/pipermail/cffi-devel/2016-October/003007.html

C2FFI Generates Invalid Macro File for GStreamer

I'm trying to use cl-autowrap (and thus c2ffi) to generate wrappers for GStreamer 1.0. Unfortunately, c2ffi crashes with a segfault in the process of this. I'm not sure if this is due to a fault on my behalf or if the gstreamer headers are simply too complex to grok.

The cl-autowrap call I'm using is:

(autowrap:c-include
 "/usr/include/gstreamer-0.10/gst/gst.h"
 :sysincludes '("/usr/include/gstreamer-0.10"
                "/usr/include/glib-2.0"
                "/usr/lib/glib-2.0/include"
                "/usr/include/libxml2")
 :trace-c2ffi cl:T)

Which executes the following two c2ffi calls, the first of which succeeds, and the second of which produces a long, long stream of errors which presumably originate from Clang.

c2ffi /usr/include/gstreamer-1.0/gst/gst.h -D null -M /tmp/tmpP44I4E0Y.tmp -A x86_64-pc-linux-gnu -i /usr/include/gstreamer-1.0 -i /usr/include/glib-2.0 -i /usr/lib/gstreamer-1.0/include -i /usr/lib/glib-2.0/include
c2ffi /tmp/tmpP44I4E0Y.tmp -o ~/gst.x86_64-pc-linux-gnu.spec -A x86_64-pc-linux-gnu -i /usr/include/gstreamer-1.0 -i /usr/include/glib-2.0 -i /usr/lib/gstreamer-1.0/include -i /usr/lib/glib-2.0/include

Since the error output is so long I've attached it. I'm running the latest Quicklisp cl-autowrap, freshly cloned c2ffi and compiled it with Clang 3.7.

Any pointers as to what I could do to get this working would be much appreciated.

Function pointer signatures

Function pointer signatures don't get displayed in the output. This may be a bug, it doesn*t seem difficult to implement.

LLVM configuration problem on El Capitan

Hi
I am trying to set up c2ffi on El Capitan. I get the following configuration error:

`Spanakorizo:c2ffi marcoxa$ cd c2ffi/
Spanakorizo:c2ffi marcoxa$ mkdir build
Spanakorizo:c2ffi marcoxa$ cd build/
Spanakorizo:build marcoxa$ cmake ..
-- The C compiler identification is AppleClang 7.3.0.7030031
-- The CXX compiler identification is AppleClang 7.3.0.7030031
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:15 (find_package):
Could not find a package configuration file provided by "LLVM" (requested
version 3.7) with any of the following names:

LLVMConfig.cmake
llvm-config.cmake

Add the installation prefix of "LLVM" to CMAKE_PREFIX_PATH or set
"LLVM_DIR" to a directory containing one of the above files. If "LLVM"
provides a separate development package or SDK, be sure it has been
installed.

-- Configuring incomplete, errors occurred!
See also "/Users/marcoxa/Projects/Software/c2ffi/c2ffi/build/CMakeFiles/CMakeOutput.log".
Spanakorizo:build marcoxa$ which llvm
Spanakorizo:build marcoxa$
`

Now. What exactly should I do? AFAIU my LLVM lives in
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

What am I missing? Do I really really have to set up a separate LLVM installation on my machine?

Thanks

Marco

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.