Skip to content

How to handle shared sub's? #285

@schorsch3000

Description

@schorsch3000

i've tried to organize my code in modules.

Every module has at least one shares sub-routine and may have it's own subroutines.

When using modules from other code-files i need to include them, but if they also use other modules i need to keep track of the order of includes.

i've tried to work around that by declaring them first, but declare seems only to work in the same file that sub is actually created, is this intended behavior?

if so: does that mean that circular dependencies only can be resolved within a single file?

i've dumbed down my particiular problem in three simple files:

main.bas:

INCLUDE "subs.bas"
call clear_keyboard_buffer()

subs.bas: (this should handle a lot of modules in the real world)

DECLARE SUB clear_keyboard_buffer() SHARED STATIC
INCLUDE "clear_keyboard_buffer.bas"

and finally
clear_keyboard_buffer.bas:

SUB clear_keyboard_buffer() SHARED STATIC
  DIM c AS byte
  c = 1
  DO WHILE c <> 0
    GET c
  LOOP
END SUB

when compiling main.bas i get:

xcbasic3 bug/main.bas 
** NOTICE ** Output file not specified, defaulting to bug/main.prg
clear_keyboard_buffer.bas:2.0: ERROR: Routine 'clear_keyboard_buffer()" must be defined as its prototype

how should i handle that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions