Rust use vs mod?

Consider you have a module my_mod with a pub function my_func. You can’t use this function in your crate (or outside your crate) until you include your module using mod my_mod statement. After you include your module, you can use your function like that: mod my_mod; … my_mod::my_func(…) … You can’t use my_mod::my_func statement if … Read more

How to tell g++ compiler where to search for include files?

As you’ve already been told, it’s useful to read the manual – specifically this chapter – and even more specifically right here. Specifically, you want g++ -I/root/workingdirectory -I/root/workingdirectory2 Note also the documentation on #include directive syntax, described here as: 2.1 Include Syntax Both user and system header files are included using the preprocessing directive #include. … Read more

Specifying include directories on the cmake command line

If the path to your headers is fixed in relation to your sources, then you should be able to avoid having to pass this info via the command line. Say your project’s directory structure is: /CMakeLists.txt /my_sources/main.cpp /my_sources/foo.cpp /my_includes/foo.hpp and in your CMakeLists.txt, you currently have something like: add_executable(MyExe my_sources/main.cpp my_sources/foo.cpp) then to add the … Read more

What does #include actually do?

Logically, that copy/paste is exactly what happens. I’m afraid there isn’t any more to it. You don’t need the ;, though. Your specific example is covered by the spec, section 6.10.2 Source file inclusion, paragraph 3: A preprocessing directive of the form # include “q-char-sequence” new-line causes the replacement of that directive by the entire … Read more

tech