2012-04-12 7 views
0

Ich versuche eine C-Bibliothek (libcss) in Objective C zu implementieren. Ich bekomme eine "zu viele Argumente zu funktionieren Aufruf, erwartet 4, haben 13" auf Funktion css_stylesheet_create()css_stylesheet_create() in libcss (Fehler: zu viele Argumente zum Funktionsaufruf)

code = css_stylesheet_create(CSS_LEVEL_DEFAULT, "UTF-8", "", NULL, 
          false, false, myrealloc, 0, resolve_url, 0, NULL, NULL, 
          &sheet); 

css_stylesheet_create Definition:

/** 
    * Parameter block for css_stylesheet_create() 
    */ 

    typedef struct css_stylesheet_params { 
      /** ABI version of this structure */ 
      uint32_t params_version; 


      /** The language level of the stylesheet */ 
      css_language_level level; 
      /** The charset of the stylesheet data, or NULL to detect */ 
      const char *charset; 
      /** URL of stylesheet */ 
      const char *url; 
      /** Title of stylesheet */ 
      const char *title; 

      /** Permit quirky parsing of stylesheet */ 
      bool allow_quirks; 
      /** This stylesheet is an inline style */ 
      bool inline_style; 

      /** URL resolution function */ 
      css_url_resolution_fn resolve; 
      /** Client private data for resolve */ 
      void *resolve_pw; 

      /** Import notification function */ 
      css_import_notification_fn import; 
      /** Client private data for import */ 
      void *import_pw; 

      /** Colour resolution function */ 
      css_color_resolution_fn color; 
      /** Client private data for color */ 
      void *color_pw; 

      /** Font resolution function */ 
      css_font_resolution_fn font; 
      /** Client private data for font */ 
      void *font_pw; 
    } css_stylesheet_params; 

css_error css_stylesheet_create(const css_stylesheet_params *params, 
     css_allocator_fn alloc, void *alloc_pw, 
     css_stylesheet **stylesheet); 
+0

Ich bearbeitete meine Antwort mit neuen Daten. Check out und sehen, ob es hilft –

Antwort

3

der Prototyp für 4 Parameter fragt und der Anruf hat 13 Parameter!

Überprüfen Sie diese patch. Sie ändern die css_stylesheet_create Funktion insgesamt. dh sie sind die Einbettung aller Parameter innerhalb css_stylesheet_params wodurch die Anzahl der params reduziert auf css_stylesheet_create 13-4

Sie müssen also

css_stylesheet_params params; 

params.level = CSS_LEVEL_DEFAULT; 
params.charset = "UTF-8"; 
params.url = ""; 
params.title = NULL; 
params.allow_quirks = false; 
params.inline_style = false; 
params.resolve = resolve_url; 
params.resolve_pw = NULL; 
params.import = NULL; 
params.import_pw = NULL; 
params.color = NULL; 
params.color_pw = NULL; 

css_stylesheet_create(&params, myrealloc, NULL, &sheet) 
+0

Ich bin neu in "pure C", also war ich ahnungslos. (Der Funktionsaufruf war von libcss Beispielcode, also dachte ich, der Code war korrekt. Aber es scheint kaputt zu sein.) – Olof

+0

@Olof Ja, es passiert. Beispiel Code wäre veraltet und es wird nicht erwähnt werden, und wir werden in Suppe sein :(. Es ist OK. Es gibt eine Lösung für alles :) –

1

Ja wie this- nennen, Check-out, in Ihrer Funktion Erklärung Sie haben gab nur 4 Parameter, aber Sie rufen die Funktion mit mehr als 4 Argumente auf