oneTBB icon indicating copy to clipboard operation
oneTBB copied to clipboard

Cannot initialize a parameter of type 'const tchar *' (aka 'const wchar_t *') with an lvalue of type 'const char *'

Open Data-Adventure opened this issue 2 years ago • 11 comments

When using clion to build my project, only then # includepost compilation process reported an error. The following figure shows a bug image image

Data-Adventure avatar Mar 27 '23 13:03 Data-Adventure

Here is the process: ====================[ 构建 | tobacco | Debug ]==================================== E:\toolbox\apps\CLion\ch-0\223.8836.42\bin\cmake\win\x64\bin\cmake.exe --build F:\tobacco\cmake-build-debug --target tobacco -j 12 [1/2] Building CXX object CMakeFiles/tobacco.dir/codetest.cpp.obj FAILED: CMakeFiles/tobacco.dir/codetest.cpp.obj E:\mingw64\bin\c++.exe -DFMT_SHARED -DTBB_USE_DEBUG -isystem E:/opencv/opencv/mingw-build -isystem E:/opencv/opencv/sources/include -isystem E:/opencv/opencv/sources/modules/core/include -isystem E:/opencv/opencv/sources/modules/flann/include -isystem E:/opencv/opencv/sources/modules/imgproc/include -isystem E:/opencv/opencv/sources/modules/ml/include -isystem E:/opencv/opencv/sources/modules/photo/include -isystem E:/opencv/opencv/sources/modules/dnn/include -isystem E:/opencv/opencv/sources/modules/features2d/include -isystem E:/opencv/opencv/sources/modules/imgcodecs/include -isystem E:/opencv/opencv/sources/modules/videoio/include -isystem E:/opencv/opencv/sources/modules/calib3d/include -isystem E:/opencv/opencv/sources/modules/highgui/include -isystem E:/opencv/opencv/sources/modules/objdetect/include -isystem E:/opencv/opencv/sources/modules/stitching/include -isystem E:/opencv/opencv/sources/modules/ts/include -isystem E:/opencv/opencv/sources/modules/video/include -isystem E:/opencv/opencv/sources/modules/gapi/include -isystem E:/vcpkg/installed/x64-windows/include -isystem E:/vcpkg/installed/x64-windows/include/eigen3 -fopenmp -g -fdiagnostics-color=always -std=gnu++20 -MD -MT CMakeFiles/tobacco.dir/codetest.cpp.obj -MF CMakeFiles\tobacco.dir\codetest.cpp.obj.d -o CMakeFiles/tobacco.dir/codetest.cpp.obj -c F:/tobacco/codetest.cpp In file included from e:\vcpkg\installed\x64-windows\include\oneapi\tbb\detail/_small_object_pool.h:23, from e:\vcpkg\installed\x64-windows\include\oneapi\tbb\detail/_task.h:23, from e:\vcpkg\installed\x64-windows\include\oneapi\tbb\parallel_for.h:23, from E:/vcpkg/installed/x64-windows/include/tbb/parallel_for.h:17, from e:\mingw64\include\c++\12.2.0\pstl\parallel_backend_tbb.h:20, from e:\mingw64\include\c++\12.2.0\pstl\parallel_backend.h:20, from e:\mingw64\include\c++\12.2.0\pstl\algorithm_impl.h:22, from e:\mingw64\include\c++\12.2.0\pstl\glue_execution_defs.h:50, from e:\mingw64\include\c++\12.2.0\execution:32, from F:/tobacco/codetest.cpp:6: e:\vcpkg\installed\x64-windows\include\oneapi\tbb\profiling.h: In function 'void tbb::detail::d1::itt_set_sync_name(void*, const char*)': e:\vcpkg\installed\x64-windows\include\oneapi\tbb\profiling.h:148:36: error: cannot convert 'const char*' to 'const tbb::detail::d0::tchar*' {aka 'const wchar_t*'} 148 | r1::itt_set_sync_name(obj, name); | ^~~~ | | | const char* e:\vcpkg\installed\x64-windows\include\oneapi\tbb\profiling.h:80:83: note: initializing argument 2 of 'void tbb::detail::r1::itt_set_sync_name(void*, const tbb::detail::d0::tchar*)' 80 | TBB_EXPORT void __TBB_EXPORTED_FUNC itt_set_sync_name(void* obj, const tchar* name); | ~~~~~~~~~~~~~^~~~ ninja: build stopped: subcommand failed.

Data-Adventure avatar Mar 27 '23 13:03 Data-Adventure

Hi @nightvoyager-xxs, Could you please try to build oneTBB with this compiler?

pavelkumbrasev avatar Mar 27 '23 13:03 pavelkumbrasev

Hi, I'm sorry to revive this issue but did you manage to find the solution to this error? I'm having the exact same problem. @Data-Adventure

ldkuba avatar Dec 03 '23 20:12 ldkuba

I have the same problem.. image image image

white-echidna avatar Dec 16 '23 11:12 white-echidna

Hi @exldna ,

Thank you for reporting this. Can you please provide a reproducer. I tried on mingw environment on Windows and couldn't reproduce it. I also need to know the cmake build cmd you used - especially the generator option (-G) set by you.

sarathnandu avatar Dec 19 '23 15:12 sarathnandu

I am trying to run the example code from the MS docs, and I get the following compilation error:

Creating a View Within a File

https://learn.microsoft.com/en-us/windows/win32/memory/creating-a-view-within-a-file

Severity Code Description Project File Line Suppression State Error (active) E0144 a value of type "const wchar_t *" cannot be used to initialize an entity of type "TCHAR *" FileIO_example_01 K:\Software Development\aaa_PlayGround\20240328_WinFileIO\WinFileIO_01\FileIO_example_01\FileIO_example_01.cpp 45

Error C2440 'initializing': cannot convert from 'const wchar_t [11]' to 'TCHAR *' FileIO_example_01 k:\software development\aaa_playground\20240328_winfileio\winfileio_01\fileio_example_01\fileio_example_01.cpp 45

EDIT: I managed to get it to compile.

//TCHAR * lpcTheFile = (TCHAR *) TEXT("fmtest.txt"); // the file to be manipulated

const TCHAR * lpcTheFile = (TCHAR *) "fmtest.txt"; // the file to be manipulated

When I ran the executable, the file name for the test file ("fmtest.txt") was mangled, and the generated content is hex/binary from what I can tell.

wally96334 avatar Mar 31 '24 02:03 wally96334

@wally96334 is this issue still relevant?

nofuturre avatar Jul 12 '24 11:07 nofuturre

I can reproduce the issue on latest master under mingw. Specifically, I used a fresh install of mingw winlibs, and the mingw makefiles generator for the initial setup. (I can build tbb using the visual studio toolchain, but can't even link with the devel libraries under mingw once they are installed due to this issue.)

tibetiroka avatar Jul 14 '24 13:07 tibetiroka