Brian Dolan
Brian Dolan

Reputation: 3136

Include second source file in Chapel file

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?

Upvotes: 4

Views: 78

Answers (1)

Lydia Duncan
Lydia Duncan

Reputation: 617

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

Upvotes: 3

Related Questions