2012-04-12 130 views
0

我試圖在Objective C中實現一個C庫(libcs​​s)。我得到一個「函數調用的參數太多,期望值爲4,有13" 個在功能css_stylesheet_create()libcs​​s中的css_stylesheet_create()錯誤:函數調用的參數太多

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

css_stylesheet_create定義:

/** 
    * 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

我編輯了我的答案與新的數據。看看是否有幫助 – 2012-04-12 13:46:19

回答

3

原型詢問4個參數和呼叫有13個參數!

檢查此patch。他們完全改變了css_stylesheet_create的功能。即它們嵌入所有參數裏面css_stylesheet_params從而減少則params的數量css_stylesheet_create從13到4

所以,你需要像這個 -

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

我是「純C」的新手,所以我很無能。 (函數調用來自libcs​​s示例代碼,所以我認爲代碼是正確的,但它似乎被破壞了。) – Olof 2012-04-12 13:47:42

+0

@Olof是的它發生了。示例代碼將過時,並且將不會提及它,我們將在湯:(它確定。有一個解決方案的一切:) – 2012-04-12 13:49:26

1

調用是,退房,在你的函數聲明中,您有給出只有4個參數,但你調用的函數有4個以上的參數

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