May 16, 2024, 07:11:30 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Can compiler warnings be turned off?

Started by Robert34, August 16, 2008, 05:46:27 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Robert34

I just started using EBasic 1.63 and my program has a lot of unreferenced variables in subroutines. These cause a lot of warnings to be printed in the output window. Although the program works ok, it would be nice to turn off these warnings. Is there a compiler option for this?

When I first installed Ebasic, I put it in the C:\Program Files folder. Then Vista won't let me compile any of the sample projects because the folders are flagged as "read-only" and the exe file can't be written back to the HD.  Even though I'm the only one who uses this computer, I can't seem to clear the read-only attributes in the Program Files folder. I finally had to copy the project files to another folder. Does anyone know how to get around this?

Thanks,
Robert 

 

LarryMc

From another posting on the forum
QuoteThe first big thing is that Vista has something called the UAC (User Account Control) that warns you whenever the operating system thinks you're doing something potentially dangerous. Actually, "warn" is an understatement. When this happens, a top-level dialog gets focus and the entire desktop "greys out"; you can't bypass it, and you can't ignore it. You have to respond to the prompt, to either accept the action or not. You can disable UAC, but then you get security warnings that your system is at risk.

I disabled UAC on my wife's laptop.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

From the release annoucement for v1.63:
QuoteThe installation now puts the projects directory under: "My Documents\Emergence Basic\projects" which will allow Vista users to compile that example programs without needing to copy them somewhere else on the drive first.  You can always move them after the installation to where ever you want.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Ionic Wind Support Team

The warnings are there for a reason.  Unreferenced variables means you are defining variables but not using them, easy enough to get rid of that warning. Uninitialized variables means you are using a variable before it has been initialized in the subroutine, and the warning is important since local variables are guaranteed to contain random data as they are located on the stack.  Consider this subroutine:


sub bad_practice
int a
int b
int c
  for a =  1 to 100
    b = b + 1
  next a
print b
endsub


You will get two warnings.  Unreferenced local variable because C is never used, and uninitialized variable because the contents of B are undefined when the FOR loop starts.   The warning is there to protect you from writing bad code:


sub good_practice
int a
int b
a = 0
b = 0
  for a =  1 to 100
    b = b + 1
  next a
print b
endsub


While it is not technically necessary to initialize A in this example as the FOR statement does it, you should get into the habit of always initializing local variables, otherwise you will run into some very hard to find bugs when your programs get to be thousands of lines in size.

Paul.
Ionic Wind Support Team

Ionic Wind Support Team

I am sure he was taking about 1.62 Larry, since he isn't a subscriber he can't have 1.63.
Ionic Wind Support Team