gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about using GSInitializeProces()


From: Richard Frith-Macdonald
Subject: Re: Question about using GSInitializeProces()
Date: Thu, 3 Apr 2014 06:33:33 +0100

On 3 Apr 2014, at 00:12, address@hidden wrote:

> I’m moving from Cocoa to GNUStep.  This decision came from having to switch 
> to a Windows based laptop over a MacBook Pro. The decision to go with GNUStep 
> was a pretty easy one, but there’s a few things I need to figure out that I 
> cannot find any good documentation on. Particularly, the GSInitializeProces() 
> function. The documentation is pretty simple, just listing the arguments that 
> it takes, and every example I’ve found passes arguments that don’t actually 
> match the function’s declaration. 

That seems strange ... the arguments are just those normally provided to the 
main() function.  There's no special trick to this, and the normal expected 
ussage would simply be of the form:

int main (int argc, char *argv[], char *envp[])
{
  GSInitializeProcess(argc, argc, envp);
  ...
  return 0;
}

The function is really not necessary on ms-windows ... it's recommended for 
portability to systems which don't provide a way for NSProcessInfo to get the 
information in argc,argv, and envp directly.

> I’m trying to set some environment variables in the main function prior to 
> returning the NSApplicationMain() so that I can point the GNU System 
> variables to the App’s working directory. (To make deployable apps on Windows 
> that do not require the end user to install GNUStep.)

I'm not sure what you mean by system variables or working directory or not 
installing GNUstep.

You can define paths in GNUstep.conf (documented partly in the gnustep-make 
documentation and partly in the main gnustep-base documentation)

You can find an apps working directory using 
[NSFileManager-currentDirectoryPath]
You can find the directory your app is installed in using [NSBundle+mainBundle]

Clearly you have to install GNUstep to run any apps that use it since an app 
can't call a library method or use a resource that's not installed; so I guess 
you actually want to build a standalone application with the gnustep stuff 
included.  See the README.MinGW file in the gnustep-make Documentation 
directory (specifically the section headed 'HOW TO SHIP YOUR GNUSTEP 
APPLICATION TO WINDOWS USERS').

> Can anyone give me a solid working example of how to use 
> GSInitializeProcess() to set environment variables in the main function?

You can't actually change environment variables ... what you can do by 
providing a pointer to a different set of variables to the 
GSInitializeProcess() function is tell NSProcessInfo to report the replacement 
values rather than the real environment variables in 
[NSProcessInfo-environment] (possibly changing the behavior of code which calls 
that method).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]