Copy link to clipboard
Copied
Hello,
I am looking for how to get environment variables in FDK. I understand that in C has function: getenv( "PATH" ); however, I could not find the similar fuction in FDK. Any suggestion or comment, I would appreciate it.
Thank you,
Thai Nguyen
Copy link to clipboard
Copied
Hi,
I'm looking for the same answer.
If I include a call to "genenv" Visual Studio 9 complains :
" error C2065: 'error' : undeclared identifier"
I've tried including <stdlib.h> and <cstdlib> but to no avail.
Am I missing a linker library?
Thanks,
Anupam
Copy link to clipboard
Copied
Hi,
You haven't specified which version of Visual C++ you are using. For older versions, I've used this successfully:
#define DONT_REDEFINE
#include "stdlib.h"
StringT ws_getEnvVar(UCharT *var)
{
UCharT *value;
StringT returnStr;
value = getenv(var);
returnStr = F_StrCopyString(value);
return returnStr;
}
In VC++ 9.0, it warns that getenv() may be obsolete and unsafe, so I use this now:
#define DONT_REDEFINE
#include "stdlib.h"
StringT ws_getEnvVar(UCharT *var)
{
UCharT *value;
StringT returnStr;
errno_t err;
err = _dupenv_s(&value, NULL, var);
if(!err)
returnStr = F_StrCopyString(value);
else
returnStr = F_StrCopyString("");
free(value);
return returnStr;
}
I'm not smart enough to fully understand the long-term consequencies of preventing the redefinition of types, so I have a single C file in my projects that handles all standard C activities and uses the DONT_REDEFINE inclusion. Note that you must have this line before #include fdetypes.h, as in:
#define DONT_REDEFINE
#include "fapi.h"
#include "fdetypes.h"
Copy link to clipboard
Copied
There must be some keystroke that automatically clicks the Post button and that is quite annoying indeed. Anyway, I think that's about it.
Russ
Copy link to clipboard
Copied
Thanks. That worked.
The magic of the #define DONT_REDEFINE made it work.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more