Как исправить «нет подходящей функции для вызова wprintf» в libclang на windows 'visual studio 2015 - PullRequest
0 голосов
/ 09 октября 2019

Я использую libclang для анализа кода, потому что в моем проекте слишком много файлов, поэтому мне нужны предварительно скомпилированные заголовки clang для ускорения.

Сначала я сохраняю файл pch на диске, но при его использовании,libclang выдает ошибки.

 const char* custom_args[] = {
    "-fms-extensions",
    "-fms-compatibility",
    "-fms-compatibility-version=19.0.24215",
    "-std=c++17",
    "-fcxx-exceptions",
    "-fexceptions",

    "-fshort-wchar",


    "-v",
    "-w",
    "-xc++-header",
    "D:\\src\\stdafx.h",
};

// Create and save pch.
CXTranslationUnit tu = clang_parseTranslationUnit(idx, NULL,
        cl_argv, cl_argc,
        NULL, 0,
        CXTranslationUnit_ForSerialization | CXTranslationUnit_CreatePreambleOnFirstParse);


    clang_saveTranslationUnit(tu,
        "D:\\src\\stdafx.h.pch", clang_defaultSaveOptions(tu));

// using pch to speed the procedure of parsing another file.
const char* code_args[] = {
    "-fms-extensions",
    "-fms-compatibility",
    "-fms-compatibility-version=19.0.24215",
    "-std=c++17",
    "-fcxx-exceptions",
    "-fexceptions",

    "-fshort-wchar",

    "-v",
    "-w",
    "-xc++",
    "-include-pch",
    "D:\\src\\stdafx.h.pch",
    "D:\\src\\my_file.cpp"
};
CXTranslationUnit tu = clang_parseTranslationUnit(idx, NULL,
        code_cl_argv, code_cl_argc,
        NULL, 0,
        CXTranslationUnit_KeepGoing);

Ошибка libclang выглядит следующим образом:

D:\src\my_file.cpp:66:5: error: no matching function for call to 'wprintf'
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_wstdio.h:605:37: note: candidate function not viable: no known conversion from 'asl::char16 *' (aka 'unsigned short *') to 'const wchar_t *const' for 1st argument

Может ли кто-нибудь помочь мне решить эту проблему?

...