English 中文(简体)
cs_esheet_create() in libcs (error: 太多的论点需要发挥作用)
原标题:css_stylesheet_create() in libcss (error: too many arguments to function call)

I ́m 试图在目标C中实施C-library (libcs) ,我收到了一份的“许多要求采取行动的论点”,预期4在职能上有13个“

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

cs_esheet_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);
最佳回答

原型要求4个参数,电话有13个参数!

。 它们正在完全改变<代码>cs_esheet_create的功能。 也就是说,它们将所有参数纳入<代码>cs_esheet_params/code>。 因此,将准绳数目从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)
问题回答

是的,在你的职责声明中,你只给出了4个参数,但你以4个以上的论据称职。

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




相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...