Skip to content

$INCLUDE_ONCE #240

Closed
Closed
@grymmjack

Description

@grymmjack

It would be fantastic if we had a pre-compiler statement that made sure the file being $INCLUDEd is only included once.

In C this is #pragma once I believe.

Why would it help?

We could avoid having to handle our own defines all over our code.

Here is an example of where I have had to implement my own include "guards":

Once at the top of the file for the .BI:

$IF GJ_LIB_ANSI_INC_BI = UNDEFINED THEN
'$INCLUDE:'ANSI.BI'
$END IF

From: https://github.com/grymmjack/QB64_GJ_LIB/blob/ad1a293001575a705daf718a6d68da79ec4c2f58/ANSI/ANSI.BAS#L13

Then at the bottom of the file for the .BM:

$IF GJ_LIB_ANSI_INC_BM = UNDEFINED THEN
'$INCLUDE:'ANSI.BM'
$END IF

https://github.com/grymmjack/QB64_GJ_LIB/blob/ad1a293001575a705daf718a6d68da79ec4c2f58/ANSI/ANSI.BAS#L793

I know this is an extreme case, but my library could be cleaned up quite a bit if we just had a feature like this.

Thanks for listening!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    • Status

      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions