Skip to content

Include files once, regardless of how many times they are included #2

Open

Description

@sunjay

I thought about adding some sort of #pragma once equivalent to the assembly language, but it occurs to me that I might really want the default behaviour of .include to only include the file once, regardless of how many times it is included. This solves a host of issues, including problems with recursive includes. It also means that you don't have to remember to annotate your file in some special way in order to get it to only be included once.

Some thought needs to be put into how we decide which include to expand. For example, we can get wildly different results if our include process is breadth-first vs. depth-first. We probably want breadth-first because then we will favour expanding includes that are found earlier in the include resolution process. That means that if you have a bunch of includes in your main file, but also repeat those includes elsewhere to indicate dependencies, only the includes in the main file will be expanded to something.

We should also consider having some sort of syntax for explicitly including a file multiple times. Having the syntax on the .include directive makes the behaviour configurable. If we used something like #pragma once, we would always be limited to the behaviour configured in the file and it would be more difficult to override that.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions