Stupid question about compiler error

Started by Wilko Verweij, April 06, 2017, 03:19:18 PM

Previous topic - Next topic

Wilko Verweij

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


Wilko Verweij

Forget it. File type needs to be set to 'Normal' rather than 'Module'... Now working

Paul Squires

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.

Paul Squires
PlanetSquires Software