Multiple Source File Question

BlitzMax Forums/BlitzMax Programming/Multiple Source File Question

peltazoid(Posted 2008) [#1]
Hi, my current project has multiple source files and I have a constant that is in several of the source files, used by several functions.

all the source files are to be imported in the main file.

e.g.
filea.bmx

const COMPLETE : int = 1


fileb.bmx

const COMPLETE : int = 1


main.bmx

import "filea.bmx"
import "fileb.bmx"

const COMPLETE : int = 1



This when compiled gives a duplicate identifier error. Is there anyway round this, apart from using different names for the const?

Cheers.


Brucey(Posted 2008) [#2]
Add a filex.bmx which holds your consts.
Let filea.bmx and fileb.bmx import it.
the main file, which imports filea and fileb doesn't need to import the consts file, since the others do.


GfK(Posted 2008) [#3]
No - you can't define the same constant three times. No way around it.

Without knowing what you're trying to do its difficult to suggest an alternative solution.


peltazoid(Posted 2008) [#4]
Ah, cheers simple as that eh.

I take it there is no reason why the main file could not import 'filex' as well (it seems to compile ok like that)

Thanks.


Brucey(Posted 2008) [#5]
np :-)