SmartPascal
$Warnings
Compiler Directive
Determines whether Delphi shows compilation warnings
1   {$Warnings Off}
2   {$Warnings On}
Description
The $Warnings compiler directive determines whether Delphi shows compilation warnings or not.
 
Warnings are very useful for pointing out potential or real code problems. You should always have warnings on, and ideally always correct your code so that there are no compilation warnings. It is all too easy to see warnings as irritations, but they are there for a real purpose.
Notes
The default value is $Warnings On

$Warnings can be set on and off multiple times in your code.
Related commands
$Hints Determines whether Delphi shows compilation hints
 
Example code : Give a warning for failing to return a value from a function
var
  i : Integer;
begin
  // Set warnings on
  {$Warnings On}

  // Set i to a known value
  i := 234;

  // Show the value at the start
  ShowMessage('i     = '+IntToStr(i));

  // Call our badly performing function
  i := GetValue;

  // Show the value now
  ShowMessage('i now = '+IntToStr(i));
end;

// A function that fails to return a value!
function TForm1.GetValue: Integer;
begin
  // Do nothing!
end;
Show full unit code
   Warning message display :
  
   [Warning] Unit1.pas[57]: Return value of function 'TForm1.GetValue' might be undefined
  
   i     = 234
   i now = 12404492
 
Example code : No warning for failing to return a value from a function
var
  i : Integer;
begin
  // Set warnings off
  {$Warnings Off}

  // Set i to a known value
  i := 234;

  // Show the value at the start
  ShowMessage('i     = '+IntToStr(i));

  // Call our badly performing function
  i := GetValue;

  // Show the value now
  ShowMessage('i now = '+IntToStr(i));
end;

// A function that fails to return a value!
function TForm1.GetValue: Integer;
begin
  // Do nothing!
end;
Show full unit code
   Code gives no warning message
  
   i     = 234
   i now = 12404492