Include second source file in Chapel file

妖精的绣舞 提交于 2019-12-07 08:06:02

问题


In C++, when I need classes in 'actions.cpp' from classes.cpp I include the header, like #include <classes.h>. But trying use classes.chpl fails, is there a .h equivalent I should be using?


回答1:


Use is only for module names, not full file names. If your file classes.chpl does not have an explicit module enclosing its entire contents, then you would type

use classes;

in order to access its contents from another file.

If classes.chpl is in the same directory as the file with the use statement, that should be all that is necessary to access its symbols.

If classes.chpl is in a different directory, you would additionally need to specify its location at compile time via the -M or --module-dir flag. For example, if usesClasses.chpl has a use of classes.chpl, and classes.chpl lived in a directory named helpers, you would write

chpl -M helpers/ usesClasses.chpl

when compiling the program



来源:https://stackoverflow.com/questions/47360626/include-second-source-file-in-chapel-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!