P_tmpdir

Hi guys,

I am new to CPP. I will like to ask for P_tmpdir macro in stdlib.h where does P_tmpdir gets the temporary directory from ? Does P_tmpdir looks into the environment for the location of the temp directory, or is it a directory that is set when C++ is installed.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include <stdlib.h>


using namespace std;

int main()
    {
        cout << "\n finding P_tmp\n";
        
    	
        cout << P_tmpdir;
        return 0;
    }


 finding P_tmp
/var/tmp/


Do let me know.
Thanks!
Last edited on
There is no such a standard name as P_tmpdir. It seems an implementation defined name. You should look stdlib.h file if it is found there.
Last edited on
The path prefix defined as P_tmpdir is part of SVID (and IIRC also part of the single unix).
In unix or Unix-like implementations, it is defined (usually as either /tmp or /var/tmp) in <stdio.h>
Right found it... Thanks!!

How does it fare against GetTempPath() ?
Last edited on
GetTempPath() is a windows api function, P_tmpdir is an SVID macro. Both provide like functionality; P_tmpdir always evaluates to the same directory while GetTempPath() looks up environment variables.
P_tmpdir is still there in current POSIX too, optionally supported
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdio.h.html
P_tmpdir
[OB XSI] [Option Start] Default directory prefix for tempnam(). [Option End]

Last edited on
Topic archived. No new replies allowed.