Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - #pragma range array check calls control http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 #pragma RANGE       Array check calls control
------------------------------------------------------------------------------
 Syntax
   #pragma RANGE+|-

 Arguments
   + and - control if the option is on or off, respectively.

 Description
   The #pragma RANGE directive controls the generation of array
   range checking code in the current source module.

   By default Force  places special code in those modules that use
   arrays to check if the array dimensions are not exceeded at runtime.
   The default behavior can be overridden by the #pragma RANGE-
   directive. In this case the  array range check code is omitted. The
   #pragma RANGE+ directive can be used to override the effect of the
   -Ga compiler switch.

 Example
   #define EXAMPLE_DIRECTIV
   #include example.hdr

   #define DEBUG       // results in debug version of code to be compiled
   
   #ifdef DEBUG
      #pragma RANGE+   // enable array checks in debug version
   #else
      #pragma RANGE-   // disable array checks in production version
   #endif
   
   proc Test_862
   vardef
      char       cName
      char( 10 ) aData[ 30 ]
   enddef
   
   cName := "Heather"
   aData[ 29 ] := "Hello"   // last array element
   
   // The following assignment refers to a non-existant element of the array.
   // In the debug version, a runtime error is the result. If the problem is
   // not corrected, then in the production version the variable cName will
   // be overwritten by the overflowing assignment of aData[].
   
   aData[ 30 ] := "world"
   ? cName // prints "world" instead of "Heather" if bug is not fixed
   
   endproc

   proc main
   Test_862()
   endproc

See Also: -Ga

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson