Dear diary

Dear diary,

today I learned that it is better to use ifndef rather than ifdef if I want the IDE to keep working properly. I had a uses clause with an ifdef to include some units only from a specific delphi version and higher. But the project manager never showed these units. Also when putting classes or methods inside of some ifdef the class completion and navigating between declaration/implementation was not working. This is probably because the IDE does not parse the include file where these defines are specified in and thus ignores the code inside the ifdef. However when using the ifndef since the compiler does not see the define it includes the code.

Comments

  1. no worries, we'll replace the IDE with VIM!

    ReplyDelete
  2. Hm, perhaps those parsers come from times when ifndef did not exist so they treat it like a comment.

    ReplyDelete
  3. Ondrej Kelle No, ifdefs are parsed and evaluated very well - it's just that the parser is missing defines from include files. If the define is made in the very same unit then it works. You can easily reproduce this. Make a new project, but some dummy class in there, surround it with an ifdef on something from some inc file and class completion and navigation stops working.

    ReplyDelete
  4. Structural highlighting stops working too.

    ReplyDelete

Post a Comment