libcs​​s中的css_stylesheet_create()(错误:函数调用的参数太多)

时间:2012-04-12 13:29:14

标签: objective-c c xcode4 struct typedef

我正在尝试在Objective C中实现一个C库(libcs​​s)。我在函数 css_stylesheet_create上得到一个“函数调用的参数太多,预期为4,有13” ()

    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);

2 个答案:

答案 0 :(得分:3)

原型要求4个参数,调用有13个参数!

检查patch。他们正在完全改变css_stylesheet_create功能。即他们将所有参数嵌入css_stylesheet_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)

答案 1 :(得分:1)

是的,检查一下,在你的函数声明中你只给出了4个参数,但是你调用了4个以上参数的函数

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