Line 1847 (parser.cpp) doesn’t compile for vc141.

Issue #9 on hold
Robert created an issue

std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert; <- this line does not compile

Comments (6)

  1. Tobias Lorenz repo owner
    • changed status to open

    I first need to setup a Visual C 14.1 compiler. Let's see if there is an alternative available with it...

  2. Yuki Yamamoto

    The same issue has occurred when I tried to compile parser.cpp using Visual Studio 2015(vc140).

    It's not a bug of Vector_BLF, but of vc140(VS2015) and v141(VS2017). https://social.msdn.microsoft.com/Forums/en-US/8f40dcd8-c67f-4eba-9134-a19b9178e481/vs-2015-rc-linker-stdcodecvt-error

    According to the solution on that page, it is recommended to use wchar_t instead of char16_t.

    So I edited the function on line 1847 (parser.cpp) as follows:

    std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t> convert;
    

    And also I changed the definition of TestStructure class that is written on TestStructure.h as follows(line 130~):

    /**
    * @brief name of the executing test module or test configuration as shown in CANoe (wchar_t)
    */
    std::wstring executingObjectName;
    
    /**
    * @brief name of structure element (can change between begin/end when using CAPL function TestCaseTitle or similar (wchar_t)
    */
    std::wstring name;
    
    /**
    * @brief full informational text for event as it appears in CANoe trace window
    */
    std::wstring text;
    

    Then I succeeded compile parser.cpp, but I'm not sure this change will not be affected adversely to Vector_BLF.

    I'm glad if you can use that link as a reference.

  3. Tobias Lorenz repo owner

    I have a VS2017 running now and can confirm the issue.

    The problem with changing char16_t to wchar_t is that it's only 16-bit wide on Windows systems, but 32-bit on Linux systems. At least according to this: https://stackoverflow.com/questions/19068748/char-vs-wchar-t-vs-char16-t-vs-char32-t-c11

    I found another topic on how to fix it: https://stackoverflow.com/questions/32055357/visual-studio-c-2015-stdcodecvt-with-char16-t-or-char32-t I tested it, but it doesn't solve the issue here.

    To allow compilation with VS >= 2015, I will just add a conditional macro around it, so compilation works, it will just not show the three lines. It's anyway just an example...

  4. Log in to comment