Include paths in C-Scripts

Hi all,

I am using external code (header and source files for specific functions) in a C-Script, e.g.

#include <my_functions.c>

It all works when the included file is in the same directory as the simulation model. If the files are more than a couple, it would be nice to have them in a separate folder, but so far I couldn’t manage to use a relative path like

#include “./Lib/my_functions.c”

(same with backslash and/or <> brackets).

Is there any way to use relative paths in this context?

Thanks!

Hi Sandro,

This is possible. Perhaps your directory structure doesn’t match how you are entering the relative paths. Attached is a simple example that works. The external C files are in the “lib” folder that is in the same directory as the PLECS model.If the files were structured differently, say “proj/models/scriptTest.plecs” and “proj/lib/my_functions.c” then you would change the include to: #include "…/lib/my_functions.c"Hope this helps address your issue. Regards,Bryan

scriptTest.zip (3.41 KB)

Thanks Bryan,

your model works. I modified my #include path accordingly, and it works now.

I’m a bit surprised that to make it work we must not use “./” nor "." before the subdirectory name, although dot seems to be standard (both in UNIX and DOS) for referencing the current directory

Best,

Sandro