libcss中的css_stylesheet_create()错误:函数调用的参数太多
我试图在Objective C中实现一个C库(libcss)。我得到一个“函数调用的参数太多,期望值为4,有13" 个在功能css_stylesheet_create()libcss中的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);
原型询问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(¶ms, myrealloc, NULL, &sheet)
我是“纯C”的新手,所以我很无能。 (函数调用来自libcss示例代码,所以我认为代码是正确的,但它似乎被破坏了。) – Olof 2012-04-12 13:47:42
@Olof是的它发生了。示例代码将过时,并且将不会提及它,我们将在汤:(它确定。有一个解决方案的一切:) – 2012-04-12 13:49:26
调用是,退房,在你的函数声明中,您有给出只有4个参数,但你调用的函数有4个以上的参数
css_error css_stylesheet_create(const css_stylesheet_params *params,
css_allocator_fn alloc, void *alloc_pw,
css_stylesheet **stylesheet);
我编辑了我的答案与新的数据。看看是否有帮助 – 2012-04-12 13:46:19