首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用JetBrains Clion (C++)的Cilk plus注释

使用JetBrains Clion (C++)的Cilk plus注释
EN

Stack Overflow用户
提问于 2017-10-06 19:06:13
回答 1查看 271关注 0票数 1

我需要在我的C++程序中使用cilk +注释,如下所示:

代码语言:javascript
复制
#inlcude <cilk/cilk.h>

cilk_spawn myFunction();
cilk_sync;

我正在使用JetBrains CLion IDE,并且在宏替换后得到错误错误:无法解析'_Cilk_spawn'类型。我想知道是否有解决办法。当然,直接从我的终端使用g++,我只是添加了选项-fcilkplus,但在这种情况下,我不知道如何解决这个问题。以下是我的CMakeLists.txt文件的内容(更新):

代码语言:javascript
复制
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)

这是构建输出(更新):

代码语言:javascript
复制
/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'
EN

回答 1

Stack Overflow用户

发布于 2017-10-12 07:30:13

在用CMAKE_CXX_FLAGS创建目标之前,需要设置add_executable

但是,我建议您使用target_compile_option来代替:

代码语言:javascript
复制
target_compile_options(C__Threads PUBLIC -fcilkplus)

当然,这必须在add_executable之后完成。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46612379

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档