[MINC-development] patches for tmpnam

Vicka Corey minc-development@bic.mni.mcgill.ca
Thu, 6 Mar 2003 16:47:28 -0500


On Thu, Mar 06, 2003 at 03:10:40PM -0500, Robert VINCENT wrote:
> What I've done elsewhere is create a private function named something like
> "miget_temp_filename(char *)" which calls mkstemp() if that function is
> available, otherwise it calls tempnam().

This seems at least as reasonable a solution as any proposed thus far :)

There is one place (in libsrc/netcdf_convenience.c in 1.1) where there
is already a call to tempnam():
 	newfile = tempname(NULL, NULL)
...apparently so that the TMPDIR environment variable will be checked.

I don't think there is any similar functionality for checking the 
environment in mkstemp.  The calls to tmpnam() take just the one 
argument for file, without directory, and seem to interchange more 
directly with mkstemp() than the two arguments for tempnam().
Did your solution also use NULL for the first argument to tempnam()?

> My scheme requires adding a probe for "mkstemp()" in the configure script,
> so it's a lot of effort to get rid of one warning.  But such is life...

...in a current Freesurfer development build under gcc 2.96, 270 such
errors are generated, which accounts for about 1/4 of the entire output
of the build.  Centralizing the effort to fix it would be very much worth
it, at least to us!

thanks,
--vicka