PlanetSquires Forums

Support Forums => PlanetSquires Software => Topic started by: Wilko Verweij on April 06, 2017, 03:19:18 PM

Title: Stupid question about compiler error
Post by: Wilko Verweij on April 06, 2017, 03:19:18 PM
Hi, After testing FB-IDE for some time, I concluded I was not satisfied and decided to test WinFBE. Works great. Now I am running into something I do not understand. I hace the following line of code:
COMMON SHARED hAppInst AS HINSTANCE

because I want to use the instance handle later. My WinMain looks like:
FUNCTION WinMain(BYVAL hInstance AS HINSTANCE, BYVAL hPrevInstance AS HINSTANCE, BYVAL szCmdLine AS ZSTRING PTR, BYVAL nCmdShow AS LONG) AS LONG

  hAppInst = hInstance
 
  FUNCTION = 1

END FUNCTION
END WinMain(GetModuleHandleW(NULL), NULL, COMMAND(), SW_NORMAL)

This works. :)
Now I would like to move the line "COMMON SHARED hAppInst AS HINSTANCE" to a separate file. So I created COMMONS.BAS, moved the line to that module, and created the line
#INCLUDE "Modules\Commons.bas"
But that gives me the error:
error 14: Expected identifier, found 'HINSTANCE' in 'COMMON SHARED hAppInst AS HINSTANCE'

What an I doing wrong (yes I know it's a stupid question)... Yet any help is appreciated...
Wilko

Title: Re: Stupid question about compiler error
Post by: Wilko Verweij on April 06, 2017, 04:52:30 PM
Forget it. File type needs to be set to 'Normal' rather than 'Module'... Now working
Title: Re: Stupid question about compiler error
Post by: Paul Squires on April 07, 2017, 09:46:52 AM
Hi Wilko,

Just as an aside, I never use COMMON because I don't compile my sources into separate object files (FB uses the term Modules which normally have a .bas extension). I use the traditional PB approach of simply #INCLUDE'ing the source files into the main file. Doing it that way you can just use SHARED for declaring global variables.

WinFBE allows you to compile your sources into object files. As you've seen, that's the issue that you encountered. By default, when WinFBE loads a .bas file (that is not the MAIN file) then it will set the file type to be Module.