我需要使用Cilk的加註釋在我的C++程序,是這樣的:的Cilk加上使用JetBrains的克利翁IDE(C++)註釋
#inlcude <cilk/cilk.h>
cilk_spawn myFunction();
cilk_sync;
我使用JetBrains的克利翁IDE和我得到的錯誤宏替換後出錯:無法解析類型'_Cilk_spawn'。我想知道是否有任何解決方案。 當然,從我的終端直接使用g ++,我只需添加選項-fcilkplus,但在這種情況下,我不知道如何解決這個問題。 這裏是(更新)我的CMakeLists.txt文件的內容:
cmake_minimum_required(VERSION 3.8)
project(C__Threads)
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp)
set(CMAKE_CXX_FLAGS "-fcilkplus") // I've also put this one because otherwise the building process fails.
add_executable(C__Threads ${SOURCE_FILES})
target_compile_options(C__Threads PUBLIC -fcilkplus)
set(CMAKE_VERBOSE_MAKEFILE ON)
這是構建輸出(更新):
/home/leo/clion-2017.2.3/bin/cmake/bin/cmake --build /home/leo/CLionProjects/C++Threads/cmake-build-debug --target C__Threads -- -j 4
/home/leo/clion-2017.2.3/bin/cmake/bin/cmake -H/home/leo/CLionProjects/C++Threads -B/home/leo/CLionProjects/C++Threads/cmake-build-debug --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/make -f CMakeFiles/Makefile2 C__Threads
make[1]: Entering directory '/home/leo/CLionProjects/C++Threads/cmake-build-debug'
/home/leo/clion-2017.2.3/bin/cmake/bin/cmake -H/home/leo/CLionProjects/C++Threads -B/home/leo/CLionProjects/C++Threads/cmake-build-debug --check-build-system CMakeFiles/Makefile.cmake 0
/home/leo/clion-2017.2.3/bin/cmake/bin/cmake -E cmake_progress_start /home/leo/CLionProjects/C++Threads/cmake-build-debug/CMakeFiles 2
/usr/bin/make -f CMakeFiles/Makefile2 CMakeFiles/C__Threads.dir/all
make[2]: Entering directory '/home/leo/CLionProjects/C++Threads/cmake-build-debug'
/usr/bin/make -f CMakeFiles/C__Threads.dir/build.make CMakeFiles/C__Threads.dir/depend
make[3]: Entering directory '/home/leo/CLionProjects/C++Threads/cmake-build-debug'
cd /home/leo/CLionProjects/C++Threads/cmake-build-debug && /home/leo/clion-2017.2.3/bin/cmake/bin/cmake -E cmake_depends "Unix Makefiles" /home/leo/CLionProjects/C++Threads /home/leo/CLionProjects/C++Threads /home/leo/CLionProjects/C++Threads/cmake-build-debug /home/leo/CLionProjects/C++Threads/cmake-build-debug /home/leo/CLionProjects/C++Threads/cmake-build-debug/CMakeFiles/C__Threads.dir/DependInfo.cmake --color=
make[3]: Leaving directory '/home/leo/CLionProjects/C++Threads/cmake-build-debug'
/usr/bin/make -f CMakeFiles/C__Threads.dir/build.make CMakeFiles/C__Threads.dir/build
make[3]: Entering directory '/home/leo/CLionProjects/C++Threads/cmake-build-debug'
[ 50%] Building CXX object CMakeFiles/C__Threads.dir/main.cpp.o
/usr/bin/c++ -fcilkplus -g -fcilkplus -std=gnu++11 -o CMakeFiles/C__Threads.dir/main.cpp.o -c /home/leo/CLionProjects/C++Threads/main.cpp
[100%] Linking CXX executable C__Threads
/home/leo/clion-2017.2.3/bin/cmake/bin/cmake -E cmake_link_script CMakeFiles/C__Threads.dir/link.txt --verbose=1
/usr/bin/c++ -fcilkplus -g CMakeFiles/C__Threads.dir/main.cpp.o -o C__Threads
make[3]: Leaving directory '/home/leo/CLionProjects/C++Threads/cmake-build-debug'
[100%] Built target C__Threads
make[2]: Leaving directory '/home/leo/CLionProjects/C++Threads/cmake-build-debug'
/home/leo/clion-2017.2.3/bin/cmake/bin/cmake -E cmake_progress_start /home/leo/CLionProjects/C++Threads/cmake-build-debug/CMakeFiles 0
make[1]: Leaving directory '/home/leo/CLionProjects/C++Threads/cmake-build-debug'
Clion爲其項目使用[CMake](https://cmake.org/)。我建議你閱讀它的[文檔](https://cmake.org/cmake/help/latest/index.html)。 –
問題不在於CMake。我想我設法通過了-fcilkplus選項,但IDE不會編譯(cilk_spawn關鍵字下仍然有紅色的波浪線)。 – leqo
如果您[閱讀'cilk-plus'標籤信息](https://stackoverflow.com/tags/cilk-plus/info)它說「**英特爾®** Cilk™Plus是C和C++的擴展「(強調我的)。像這樣的英特爾語言擴展通常只在英特爾編譯器中使用,您確定GCC支持它嗎? –