Häufig gestellte Fragen

Brauchen Sie technischen Support?

Read the current project directory in C-Code

Frage

How can I determine the current CarMaker project directory when using the C-Code interface?

Antwort

The CarMaker Simulation Program (e.g. CarMaker.win64.exe) always requires a valid CarMaker project folder as its working folder.

This is the case if the Simulation Program is started via the CarMaker-GUI but also if no GUI is used (if the Simulation Program is started without providing a valid project directory, an error is thrown).

Please note that this is not the case when using CarMaker for Simulink, where the working directory or Matlab is usually the src_cm4sl folder inside the CarMaker project.

This means that in order to determine the project directory, in most cases, you simply need to determine the current working folder of the executable.
To do so you can use the standard C-Code function getcwd:

Linux:

#include <unistd.h>
char *getcwd(char *
buf, size_t size);

Windows:

#include <direct.h>
char *_getcwd(char *buf, int _SizeInBytes);

Brauchen Sie technischen Support?
  • Datum: 20.10.2020
  • Produkt: CarMaker
  • Version: 12.0
  • Komponente: C-Code Interface
  • Sprache: Englisch

Tags

Simulation Program
getcwd
Current Working Directory