I figure there is some obscure rule I haven't found in the documentation and/or forum, but I've tried and I'm baffled. I can work around it by moving the define outside the ifdef, but I was trying to neatly encapsulate the serial stuff with an ifdef.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
#chip 16F18044, 32 ' 32MHz
#Option Explicit
#define SerialOutput
// #startup InitPPS, 85 ' have to run PPS Before HSER runs
#script
if def(SerialOutput) then
USART_DELAY = OFF
USART_BAUD_RATE = 115200 ' Define desired baud rate
USART_TX_BLOCKING = True
INFO "Serial Setup"
else
INFO "Serial Not setup"
end if
#endscript
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Got strange results with USART_DELAY OFF and #ifdef ... #endif.
If the delay setting is inside the ifdef...endif, I get
IFDEF/OFF: USART_DELAY equates to 1MS and cannot be reassigned to equate to OFF
Moving it outside the #ifdef... #endif produces no error. There are other #defines inside the ifdef that produce no error.
... produces the error message, moving it above the #ifdef does not reproduce the error.
Moving it after USART_BLOCKING also causes the error.
Particulars:
GCBASIC (2026.09.27(Windows 64 bit) : Build 1653)
I figure there is some obscure rule I haven't found in the documentation and/or forum, but I've tried and I'm baffled. I can work around it by moving the define outside the ifdef, but I was trying to neatly encapsulate the serial stuff with an ifdef.
A script is the answer.
Untested, but, a script is the method to use.
Last edit: Anobium 2026-10-04
Correct/tested and it works