Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How are compile time contstants set?

Status
Not open for further replies.

StewartUK

Programmer
Feb 19, 2001
860
GB
I suppose I'm just curious but...

I picked up Craig's program in faq184-4264 and put it in a program.

I thought I would be (ahem) clever [blush] and moved all the #DEFINE statements to the bottom of the file so that the part that does the work is seen as soon as the prg is edited.

My thinking was that the compiler would pick up the constants wherever they appeared in the prg file. However that is clearly not the case!!

As I say, it's mostly curiosity, but does anyone know how the compiler does its work?

Thanks,

Stewart
 
It's no 2 pass parsing.

#DEFINEs are needed beforehand. There is also #UNDEF, which enables you to redefine constants from a certain line on, so it wouldn't make much sense to make a 2 pass parsing of the file and then use the constants found.

What you can do is put all the defines in one file and #Include it.

Bye, Olaf.
 
Thanks for the extra information Olaf. As you suggest, I decided in the end to put them in a separate file.

Stewart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top