@hyc i use scmp/slen in this code:
https://av.vimuser.org/mkhtemp-nvmutil-wip.c.txt
note that this version is work-in-progress (not committed yet). it's for nvmutil, my mac address editor for Intel GbE NVM config, which has now turned into me replacing mktemp.
i call it: mkhtemp
dir support added later (for now files only). it resists TOCTUO attacks, and when it's done, standalone mkhutil util will also be modified to work like regular mktemp when you type "mktemp" - otherwise if typing mkhtemp, it will be hard af.