uxlfoundation / oneTBB

oneAPI Threading Building Blocks (oneTBB)
https://uxlfoundation.github.io/oneTBB/
Apache License 2.0
5.75k stars 1.02k forks source link

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

Open Data-Adventure opened 1 year ago

Data-Adventure commented 1 year ago

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 commented 1 year ago
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. `

pavelkumbrasev commented 1 year ago

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

ldkuba commented 11 months ago

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

exldna commented 11 months ago

I have the same problem.. image image image

sarathnandu commented 11 months ago

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.

wally96334 commented 8 months ago

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.

nofuturre commented 4 months ago

@wally96334 is this issue still relevant?

tibetiroka commented 4 months ago

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.)

a-day-old-bagel commented 2 months ago

I'm experiencing what is probably the same issue.

I notice that if I simply comment out the && !__MINGW32__ on line 135 of profiling.h, the issue is resolved.

I'm guessing that perhaps the logic is flawed there when deciding whether or not to use the overloads that convert a const char* to a const wchar_t* or not, based on compiler environment.

It would be good to know if commenting out the trailing && !__MINGW32__ on that line breaks anyone else's builds.