[PD-dev] open_via_path / close file - WIndows CRT problems

Thomas Grill gr at grrrr.org
Tue Jul 3 15:19:05 CEST 2012

Hi all,
when trying to trace a bug in one of my externals i came across what could be an issue in the PD API.

The header m_pd.h exposes the function open_via_path which can be used in externals to search file in the PD search path.
On success it opens the file and returns a file handle, which can in turn be used by the external code.
This doesn't seem to be a problem on Unix-based systems.
On Windows, under certain circumstances [1], PD and the external use separate copies of the CRT, meaning that passing the file handle and using POSIX-style file functions between dynamically linked binaries is not really possible. The file handle would not be valid in the external.
This happens when at least one party is linked with the threaded static CRT, which is the default with PD and most externals.

Now, i'm wondering how this problem can have been hidden for so long. Are there no externals using open_via_path and running under Windows?
This must be a problem for all script loader externals relying on the PD path, like my py/pyext external.
Am i doing something wrong, or is there a known solution/workaround etc.?

Thanks and all the best,

[1] http://msdn.microsoft.com/en-us/library/ms235460(v=vs.80).aspx

Thomas Grill

More information about the Pd-dev mailing list