import error (import must appear at top of file)

BlitzMax Forums/BlitzMax Programming/import error (import must appear at top of file)

Nate the Great(Posted 2009) [#1]
Hi,

I was trying to make a .bmx file that I include and this .bmx file imports a bunch of c stuff at the very beginning. The problem is, even if I put include before anything else in the main program, it says import must appear at top of file.. heres a basic example of what im talking about.

game.bmx
include "get_externs.bmx"

'do game stuff here


get_externs.bmx
Import "fastmaths.c"

Extern

Function fsqr:Float( s:Float )="fsqr"

End Extern



am i doing something wrong?
can you import from an include?


Jesse(Posted 2009) [#2]
I believe you get that when import is included in anything other than the main file.

try using include instead of import.


Dreamora(Posted 2009) [#3]
you can not import in an included file
Import must appear in the main file.


markcw(Posted 2009) [#4]
I assume it because include is before import that it causes the error.

Why not just import "get_externs.bmx"?


Nate the Great(Posted 2009) [#5]
importing get_externs.bmx did the trick.

I just didnt know you could import a .bmx :p

Thanks for the help!