The following warnings occurred:
Warning [2] Undefined array key 0 - Line: 1677 - File: showthread.php PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/showthread.php 1677 errorHandler->error_callback
/showthread.php 916 buildtree




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wrong #defined calculated value
#1
I think there's something I'm missing about the way #define values are calculated, look:

Code:
#define screenFirstCol 0 #define screenLastCol 31 #define borderFirstCol screenFirstCol #define borderLastCol screenLastCol #define oWinFirstCol borderFirstCol+1 #define oWinLastCol borderLastCol-1 ' Wrong result, 32 instead of 30: #define oWinWidth oWinLastCol-oWinFirstCol+1 cls print "Expected values in cramps:" print print "screenFirstCol(0)=";screenFirstCol print "screenLastCol(31)=";screenLastCol print "borderFirstCol(0)=";borderFirstCol print "borderLastCol(31)=";borderLastCol print "oWinFirstCol(1)=";oWinFirstCol print "oWinLastCol(30)=";oWinLastCol ' Wrong result, 32 instead of 30: print "oWinWidth(30)=";oWinWidth pause 0 stop

What's the problem?

I think #defined values are simple labels calculated by the preprocessor. Is it right? Is there any limit about the depth of the calculated values?
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)