CompuServe Thread

#2 'C' Problems

13 messages in this thread
#102403From: Chris ReaMay 4, 1990 6:36 PM
Hello Everybody… I've got a little problem here. I'm writing a simple application in 'C' and I want the user to be able to start the application from an icon. However, everytime I try and run it from an icon, the program opens up a console window of it's own that it doesn't really need. I'm using lattice. Can any body tell me how to get rid of this nasty extra console window? Is there any special strartup that I have to use for the workbench? Also, when I write a program, sometimes when I try to run it, a small requester pops up and says "Stack overflow…" is there any way to make it so that the user does NOT have to set a certain stack each time the program is to be run? (ie: Let the application set it's own stack?) PLEASE! I need help DESPERATELY for both of these problems. All answers will be appreciated. Thank you. .. Chris Rea …
#102537From: Bob RakoskyMay 5, 1990 10:27 AM
Chris, The easiest way to not have the console window opened is to use the following BLINK option: DEFINE __main=__tinymain This is part of the command line that you invoke the linker with, as in: blink from …. to …. lib … DEFINE __main=__tinymain SC SD ND One word of warning, however. If you use this option, then your program MUST NOT have any statements that expect a "stdout" file to be open (such as printf()'s that might be used in an "exception" situation), as this will most certainly result in a trip to GURU heaven. Hope this helps… …BobR
#102681From: Chris ReaMay 5, 1990 9:47 PM
Thanks alot for the reply… It's well appreciated. So that's all I have to do to not have the console? Anyhow, the program that I am writing does not use any console output, so I guess I'm OK… I use return codes in case something happens. Anyhow, would you have any idea on how to solve my other problem? That is the only thing forbidding me from releasing my program as it stands right now… I'm having problems with the Stack… I don't want it to say "Stack Overflow"… Any idea? Anyhow, thanks ALOT for the answer to the first problem. See ya later. ..Chris Rea
#102685From: Mike Roth/LatticeMay 5, 1990 10:39 PM
Chris, For the stack overflow problem, I'd recommend providing your workbench icon with a stack value large enough for your program. Select your icon and then select the menu option INFO to view your icon settings. Then set the stack in the requester to a large enough value. — Mike Roth
#102808From: Chris ReaMay 6, 1990 9:22 AM
Thanks for the info… However, will it not say "Stack Overflow" if my program is run from the CLI? Or will it search for a ".info" file and check to see what the stack should be at? Anyhow, thanks alot, Mike. BTW… Tell the guys over at Lattice to keep up the good work and the great customer support (I got 5.05a in the mail…) See ya! ..Chris Rea
#103185From: Mike Roth/LatticeMay 7, 1990 2:03 PM
If your program is run from the CLI, it adopts the stack size that the CLI is set to. You should recommend a minimum stack size to your users for running your program from the CLI. Maybe we can provide a method for setting the stack size inside the program with our next release. — Mike Roth / Lattice
#103247From: Bob RakoskyMay 7, 1990 7:19 PM
Mike, A compromise solution is available for insuring sufficient stack. It is a method that I used for the release version of Empire, and seemed cleaner/safer than attempting to reallocate the stack by the invoked program. That latter method appears to me to be fraught with danger (i.e., having to "cheat" to pull it off). All I did was modify the standard startup module (c.o) to have it determine the actual stack size and compare that to a "fixed" value that was my lower limit. If the stack was set too low, I simply issued an error message (via a recoverable alert) and terminated. It would be nice to be able to generalize this, but this would most likely require cooperation from the linker to be able to set the stack threshold at link time. (Remember that this is occurring in the startup code, so the threshold has to be set before any "user code" gets executed.) Just an idea for your consideration (and implementation, of course 🙂 …BobR
#103427From: Mike Roth/LatticeMay 8, 1990 2:45 PM
Bob, We currently handle stack allocation in the cres version of the startup code. I was thinking about letting the programmer set a defined variable such as __stacksize to define the minimum stack size needed. The startup code could then do any necessary stack allocation. I'm still thinking about this, though. I may decide this is a terrible idea tomorrow. 🙂 — Mike Roth
#104006From: Kevin FerlazzoMay 11, 1990 11:20 AM
Mike, Actually, having a variable such as __stacksize would be an nice thing! So please don't change your mind! <g> TTFN, Kev
#102930From: Chris ReaMay 6, 1990 7:24 PM
Hi again Mike… I was wondering. You know the BLink DEFINE __main=__tinymain? Well, I was just testing my program against some of the guidelines that C= sets in the RKM Libraries and Devices (running a program, checking the amount of mem, running it again, and then checking if it's any less) and I noticed that when I ran my program in the CLI, it did not eat up any memory at all However, when I started the program from the Workbench from an icon, it ate up about 2-3k each time I ran it. Is there any sa(or rather, is there a proper) way to make code so that it will start and finish in the workbench and the CLI without being a memory shark? Thanx alot. C ya (no pun intended…) ..Chris Rea
#103186From: Mike Roth/LatticeMay 7, 1990 2:05 PM
Chris, I'm unaware of any problems with freeing memory. I'll see if I can reproduce the problem and track it down. Thanks for letting me know. — Mike Roth
#103242From: Chris ReaMay 7, 1990 6:59 PM
If you want, I could send you the source code. Via CompuServe mail here, or I could send it to the Lattice BBS, if you prefer. (I am on there, but rarely call. LD charges are 36 cents a minute from Montreal to Illinois.) See ya Mike. ..Chris Rea
#103428From: Mike Roth/LatticeMay 8, 1990 2:46 PM
Chris, Just send it on here by EMail. Whatever is easier for you. — Mike Roth