If you are statically linking the runtime, then another option is to write your own version of mktemp in the object file. The component should prefer your version over the run-time version.
Change Thanks to Jason Coco for pointing out the big misunderstanding that I had at mktemp and his relatives. Now this is a little easier to solve. Since the linker will prefer the version in the object file, you just need to write mktemp in terms of mkstemp .
The only difficulties are cleaning up the file descriptors that mkstemp will return to you and make everything thread safe. You can use a static array of descriptors and an atexit registered function to clean up, if you can set a limit on the number of temporary files that you need. If not, just use a linked list.
D.Shawley
source share