Linking C++ and Cilk++ files.

Linking C++ and Cilk++ files.

I was trying to use a classfromsepeate C++ code in my Cilk++ code, and encountered compilation errors. Adding the following code at the beginning of Cilk++ code to include both header and C++ code fixed the problem. Thanks. -Hailong

CILK_BEGIN_CPLUSPLUS_HEADERS
#include
#include
CILK_END_CPLUSPLUS_HEADERS

3 帖子 / 0 全新
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项

Good tip. As a general rule, if the Cilk++ code can be isolated effectively, apart from alleviating some of the integration difficulties, you may see performance improvements.

That aside, I'd be interested to know what the compilation errors were. Were they linker errors?

Thanks for the advice. If I don't include the cpp file in Cilk++ code and try to link the object files as below:

$ g++ -c mycode.cpp
$ cilk++ -c newcode.cilk
$ cilk++ mycode.o newcode.o -o newcode.exe -O2

I would not pass the second command line. Say I have a class called myclass implemented in mycode.cpp then I would encouter errors like "myclasshas not beedeclared" or "myclass was notdeclared in this scope".

When I included both the cpp and header file in the Cilk++ code, I was able to compile the Cilk++ code in one step with no errors:

cilk++ newcode.cilk -o newcode.exe -O2

-Hailong

发表评论

登录添加评论。还不是成员?立即加入