2012-02-21 1 views
2

を__android_log_print:AndroidのNDKでのAndroid NDKと私は、このLIBを使用して

int main2() 
{ 
//load russian hyphenation patterns 
struct pattern_list_t* plist = create_pattern_list(); 
size_t i = 0; 
while (patterns[i]) 
{ 
struct pattern_t* p = create_pattern(patterns[i], isdigit_func, ismarker_func, char2digit_func); 
add_patern(plist, p); 
++i; 
} 
sort_pattern_list(plist); 

//hyphenate test words 
size_t word_index = 0; 
while (test_words[word_index]) 
{ 
struct word_hyphenation_t* wh = hyphenate_word(test_words[word_index], plist, marker); 
i = 0; 
while (test_words[word_index][i]) 
{ 
    __android_log_print(ANDROID_LOG_INFO, "HelloNDK!", "%c", test_words[word_index][i]); 
++i; 
} 

destroy_word_hyphenation(wh); 

++word_index; 
} 

//cleanup 
destroy_pattern_list(plist); 
return 0; 
} 

この作品が、私はLogCatに入る::JNIでhttps://github.com/mysolution/hyphenatorを私はこの関数を作成

2月21日16:15: 18.989:情報/ HelloNDK!(403):

この問題を解決するには?エンコードの問題だと思いますが、これを解決する方法はわかりません。

+0

私はこれがASCII文字をログアウトしようとしていることを確認できますが、私はmyString.c_str()をログアウトすることができます。しかし、__android_log_printへの別の呼び出しでは、問題はchar *の連結であるように見えるので、idはこれを修正することを知っています。私はそれを把握すると投稿します。 – Dev2rights

+0

あなたは型の不一致を持っているようですが、 'test_words'の宣言がなくてもわかりません。コンパイラは(gccはprintf形式の型を特別にサポートしていますが)可能でなければなりません。警告をオンにします。 –

答えて

0

予想される出力は何ですか?文字がASCIIの範囲外にある場合は、もちろんそれをサポートするlogcatを見るための何かが必要です。あなたがUTF-8を出力していると仮定すると、TerminatorはLinuxでうまく、WindowsではMintty(Cygwinとの組み合わせなど)です。

0

私はそれを働いた、これは私には非常に間違っているようだ.....

ので__android_log_vprintでのchar *の連結のために、あなたが脱出%sのない%cを使用する必要があると思われる__android_log_print。

これは、printf( "%s"、myString.c_str())としてiOS、Android、Blackberry間のクロスプラットフォームchar *ログを作成するための私の計画を完全に排除します。違法です。 argsを使ってファンキーにして文字列を解析する必要があります。とにかくそれは別の問題であり、あなたの修正があります....

+0

'printf("%s "、myString.c_str());は_legal_であり、唯一の正しい方法です。 "%s"は 'const char *'を期待しています。 'c_str()'メソッド( 'std :: string :: c_str()'または一致するシグネチャがあれば)が返すものです。一時表記は_statement_の終わりまで存在するので、printfがそれを処理するのに十分な時間です。 –

関連する問題