我正在尝试运行ICU4C bellow的代码演示程序,
警告:函数“自述”的隐式声明
然后生成一个错误。据我所知,这是因为缺少包含‘austr举’函数的导入库,并且一直在查看源代码来猜测它是哪一个,但没有运气。有人知道该进口哪一种吗?
#include <unicode/umsg.h>
#include <unicode/ustring.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char const *argv[])
{
UChar* str;
UErrorCode status = U_ZERO_ERROR;
UChar *result = NULL;
UChar pattern[100];
int32_t resultlength, resultLengthOut, i;
double testArgs[] = { 100.0, 1.0, 0.0};
str=(UChar*)malloc(sizeof(UChar) * 10);
u_uastrcpy(str, "MyDisk");
u_uastrcpy(pattern, "The disk {1} contains {0,choice,0#no files|1#one file|1<{0,number,integer} files}");
for(i=0; i<3; i++){
resultlength=0;
resultLengthOut=u_formatMessage( "en_US", pattern, u_strlen(pattern), NULL, resultlength, &status, testArgs[i], str);
if(status==U_BUFFER_OVERFLOW_ERROR){ //check if output truncated
status=U_ZERO_ERROR;
resultlength=resultLengthOut+1;
result=(UChar*)malloc(sizeof(UChar) * resultlength);
u_formatMessage( "en_US", pattern, u_strlen(pattern), result, resultlength, &status, testArgs[i], str);
}
printf("%s\n", austrdup(result) ); //austrdup( a function used to convert UChar* to char*)
free(result);
}
return 0;
}发布于 2020-05-18 08:28:41
austrdup不是一种正式的ICU方法。它仅用于ICU中的测试,并在icu4c/source/test/cintltst/cintltst.h中定义并在icu4c/source/test/cintltst/cintltst.c中实现。基本上,它只是u_austrcpy的包装器。
https://stackoverflow.com/questions/61837244
复制相似问题