AutoDeclare synchronizes Declare statements with existing Procedure definitions in a PureBasic .pb source file.
AutoDeclare scans one source file, detects procedures and declarations, compares them by scope and type, removes invalid declarations, and generates missing valid ones.
The tool is intended for PureBasic projects that use:
- global procedures
DeclareModuleModuleCompilerIf #PB_Compiler_IsMainFile
The processed file is overwritten in place.
This project was developed with the assistance of AI tools for research, coding support, and documentation.
If you do not want to compile the tool yourself, you can download the ready-to-use executable from the latest release.
File: LoTeK_PureBasic_PreProcessor_AutoDeclare_Win64_v0.3.0.exe
Build Environment:
- Platform: Windows 11 64-bit
- Built with: PureBasic 6.30
- Tested on: Windows 11 x64
Download: LoTeK_PureBasic_PreProcessor_AutoDeclare_Win64_v0.3.0.exe
File: LoTeK_PureBasic_PreProcessor_AutoDeclare_Linux64_v0.3.0
Build Environment:
- Platform: Ubuntu 24.04 LTS 64-bit
- Built with: PureBasic 6.30
- Tested on: Ubuntu 24.04 LTS x64
Download: LoTeK_PureBasic_PreProcessor_AutoDeclare_Linux64_v0.3.0
- generates missing declarations
- removes obsolete declarations
- removes duplicate declarations
- supports
DeclareModule - supports
Module - supports compiler scope (
CompilerIf #PB_Compiler_IsMainFile) - supports multiple modules
- processes one file at a time
Recognized scopes:
- Global
DeclareModuleModuleCompilerIf #PB_Compiler_IsMainFile
Everything outside these blocks is treated as global file scope.
DeclareModule has priority over matching Module declarations when such a DeclareModule declaration already exists.
AutoDeclare compares declarations and procedures by:
- name
- module
- scope
- type signature
The tool:
- removes wrong declarations
- removes obsolete declarations
- removes duplicate declarations
- inserts missing declarations
(X)IncludeFiledependency tracking- project-wide scanning
- ProcedureDLL
The tool inserts detected Declare statements at a sensible default location:
- in the global scope at the top of the file
- inside
DeclareModule,Module, orCompilerIf #PB_Compiler_IsMainFileblocks at the top of these sections - after
EnableExplicit, if present in a scope
Depending on the project structure, it may still be necessary to move generated Declare lines manually afterwards, for example below structure definitions, constants, prototypes, or other project-specific declaration sections.
Run the tool with a .pb file path as parameter.
Typical workflow:
- pass a source file to the tool
- declarations are analyzed against procedures
- invalid declarations are removed
- missing declarations are generated
- the file is overwritten
For manual testing, see:
tests/TestFile.pb
Show repository structure
purebasic-module-preprocessor-autodeclare
├── assets
│ └── img
│ └── Installation_PB_IDE_Screenshot_1.png
├── src
│ └── Mod_AutoDeclare.pb
├── tests
│ └── TestFile.pb
├── AGENTS.md
├── CHANGELOG.md
├── LICENSE
└── README.md
- the original file is overwritten
- no automatic backup is created
- use version control before running it on important files
MIT License
See LICENSE.
