2017-09-19 4 views
1

Ich habe einen Go-Wrapper für open-vcdiff so nahm ich einen Blick auf SWIG zum ersten Mal mit dem folgenden Versuch zu erzeugen versuchen:Ist SWIG for go veraltet, seit einige C in Golang entfernt wurden?

godelta.swig

%module godelta 
%include "include/godelta.hpp" 

godelta.hpp

#include "config.h" 
#include <assert.h> 
#include <errno.h> 
#ifdef WIN32 
#include <fcntl.h> 
#include <io.h> 
#endif // WIN32 
#include <stdio.h> 
#include "google/vcdecoder.h" 
#include "google/vcencoder.h" 
#include "google/jsonwriter.h" 
#include "google/encodetable.h" 
#include "unique_ptr.h" // auto_ptr, unique_ptr 

#ifndef HAS_GLOBAL_STRING 

#endif // !HAS_GLOBAL_STRING 

static const size_t kDefaultMaxTargetSize = 1 << 26;  // 64 MB 

namespace godelta { 

    class Godelta { 
    public: 
     Godelta(); 
     ~Godelta(); 

     bool Encode(); 
     bool Decode(); 
     bool DecodeAndCompare(); 

     int opt_buffersize; 
     int opt_max_target_window_size; 
     int opt_max_target_file_size; 

    private: 
     input file 
     static bool FileSize(FILE* file, size_t* file_size); 
     bool OpenFileForReading(const string& file_name, 
          const char* file_type, 
          FILE** file, 
          std::vector<char>* buffer); 
     bool OpenDictionary(); 
     bool OpenInputFile() { 
      return OpenFileForReading(input_file_name_, 
            input_file_type_, 
            &input_file_, 
            &input_buffer_); 
     } 

     bool OpenOutputFile(); 
     bool OpenOutputFileForCompare() { 
      return OpenFileForReading(output_file_name_, 
            output_file_type_, 
            &output_file_, 
            &compare_buffer_); 
     } 

     bool ReadInput(size_t* bytes_read); 
     bool WriteOutput(const string& output); 
     bool CompareOutput(const string& output); 

     std::vector<char> dictionary_; 

     UNIQUE_PTR<open_vcdiff::HashedDictionary> hashed_dictionary_; 

     const char* input_file_type_; 
     const char* output_file_type_; 

     string input_file_name_; 
     string output_file_name_; 

     FILE* input_file_; 
     FILE* output_file_; 

     std::vector<char> input_buffer_; 
     std::vector<char> compare_buffer_; 

     Godelta(const Godelta&); // NOLINT 
     void operator=(const Godelta&); 
    }; 

} // namespace godelta 

Swig funktioniert gut und erzeugt die Dateien godelta_wrap.cxx, godelta_gc.c und godelta.go. Das Problem, das ich jetzt mit Blick auf bin ist, dass es das Erzeugen des enthält:

#include "runtime.h" 
#include "cgocall.h" 

in dem Fehler resultierende:

godelta_gc.c:2:10: fatal error: 'runtime.h' file not found 

Ich habe überall für diese Datei angesehen, auch die Go-Repository auf GitHub gesucht. Ich finde nur, was in Go anscheinend ein Ersatz für diese Datei ist.

By the way, mein gehen Version ist:

go version go1.9 darwin/amd64 

Clang:

Apple LLVM version 8.1.0 (clang-802.0.42) 
Target: x86_64-apple-darwin16.7.0 
Thread model: posix 
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin 

Und SWIG:

SWIG Version 3.0.12 
Compiled with g++ [x86_64-apple-darwin16.7.0] 
Configured options: +pcre 

Einsicht über das Thema wird sehr geschätzt, vor allem wenn es dazu führt, dass ich go build auf der Verpackung ohne diesen Fehler ausführen kann :-)

+2

"Guthub", Ihre One-Stop-Quelle für freie Organe! ... werde ich bearbeiten, aber ich wollte diesen schönen Tippfehler für die Nachwelt bewahren;) – Thomas

+0

Autsch! Mein Fehler. Ich meine keine Respektlosigkeit gegenüber Github :-) – Sthe

Antwort

2

Es sieht so aus, als hätte ich eine Flagge auf meinem Swig-Befehl vermisst. Mein ursprünglicher Befehl sah wie folgt aus:

swig -go -intgosize 64 godelta.swig 

Aber wie auf der issue wies darauf hin, ich schließlich eingereicht, ich sollte mit -c++ und -cgo enden umfassen:

swig -c++ -go -cgo -intgosize 64 godelta.swig 

Es funktioniert jetzt gut: -)

Verwandte Themen