{{fbdoc item="title" value="COMMON"}}----
Variable declaration and scope modifier

{{fbdoc item="syntax"}}##
	**Common** [[[KeyPgShared|Shared]]] //symbolname//[()] [AS [[DataType|DataType]]] [, ...]
##
{{fbdoc item="desc"}}
	Declares a variable which is shared between code modules, including those to be compiled as static and dynamic libraries (DLLs).
	A matching ##**Common**## statement must appear in all other code modules using the variable. 
	
	##**Common**## variables cannot be initialized.
	##**Common**## arrays are always variable-length, and must be defined with an empty parameter list ##()##, and its dimensions set in a later ##[[KeyPgDim|Dim]]## or ##[[KeyPgRedim|Redim]]## statement.
	##**Common**## variables cannot be instances of a user-defined type having a constructor or a destructor even implicit.
	
	The ##**Shared**## optional parameter makes the variable global so that it can be used inside ##[[KeyPgSub|sub]]##s and ##[[KeyPgFunction|function]]##s, as well as at module level.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/module/common1.bas"}}%%(freebasic)
'' common1.bas

Declare Sub initme()

Common Shared foo() As Double

Redim foo(0 To 2)

initme()

Print foo(0), foo(1), foo(2)
%%

{{fbdoc item="filename" value="examples/manual/module/common2.bas"}}%%(freebasic)
'' common2.bas

Common Shared foo() As Double

Sub initme()
  foo(0) = 4*Atn(1)
  foo(1) = foo(0)/3
  foo(2) = foo(1)*2
End Sub
%%
After compiling the two files like:
##fbc common1.bas common2.bas##
running ##common1## produces the output:
%%
 3.141592653589793           1.047197551196598           2.094395102393195
%%
{{fbdoc item="target"}}
	- Windows does not support ##**Common**## with a dynamic library (compiled with -dll or -dylib).

{{fbdoc item="diff"}}
	- The arrays will be always variable-length.
	- ##//blockname//## is not needed and must be removed because the order of declaration no longer matters, only the symbol names.
	- ##**Common**## does not allow to keep the values of certain variables when chaining programs with ##[[KeyPgChain|Chain]]##.

{{fbdoc item="see"}}
	- ##[[KeyPgDim|Dim]]##
	- ##[[KeyPgErase|Erase]]##
	- ##[[KeyPgExtern|Extern]]##
	- ##[[KeyPgLbound|Lbound]]##
	- ##[[KeyPgRedim|Redim]]##
	- ##[[KeyPgPreserve|Preserve]]##
	- ##[[KeyPgShared|Shared]]##
	- ##[[KeyPgStatic|Static]]##
	- ##[[KeyPgUbound|Ubound]]##
	- ##[[KeyPgVar|Var]]##

{{fbdoc item="back" value="CatPgModularizing|Modularizing"}}