Author Topic: How does %include work  (Read 5977 times)

kevin

  • Guest
How does %include work
« on: February 16, 2008, 02:30:53 PM »
Does it just insert the text where the directive is called?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: How does %include work
« Reply #1 on: February 16, 2008, 03:50:15 PM »
Correct.

%include "myfile.inc"

Will "cut and paste" the contents of "myfile.inc" at that point in the file. Nasm will look in the "current" directory for "myfile.inc". That is, if you're in /home/fbk, and type "nasm src/myfile.asm", and  "myfile.asm" includes that %include, Nasm will be looking in /home/fbk not /home/fbk/src. The "-I" switch adds search paths for %include (and incbin). "nasm -I src/ src/myfile.asm" would find it. You can make this part or all of the "NASMENV" environment variable: "set NASMENV=-I/home/fbk/src/ -I/home/fbk/include/" - or whatever your OS requires ("export ..."). Still, it can be challenging to find "nested" includes. A little common sense about where you put this stuff in the first place will help. :)

Best,
Frank