2010-05-19 Jb Evain <jbevain@novell.com>
[mcs.git] / tools / monodoc / Test / man-test1.1
blob38400b816684d1704f829bc3f41b5f7993ee0d8b
1 .TH mcs 1 "6 January 2001"
2 .SH NAME 
3 mcs, gmcs, smcs \- Mono C# Compiler (1.0, 2.0, Moonlight)
4 .SH SYNOPSIS
5 .B mcs 
6 [option] [source-files]
7 .SH DESCRIPTION
8 mcs is the Mono C# compiler, an implementation of the ECMA-334
9 language specification.  You can pass one or more options to drive the
10 compiler, and a set of source files.  Extra options or arguments can
11 be provided in a response file.  Response files are referenced by
12 prepending the @ symbol to the response file name.
13 .PP
14 The 
15 .I mcs
16 compiler is used to compile against the 1.x profile and implements
17 C# 1.0 and 2.0 with the exception of generics and nullable types.
18 .PP
19 The
20 .I gmcs
21 compiler is used to compile against the 2.0 profile and implements
22 the complete C# 2.0 specification including generics.
23 .PP
24 The
25 .I smcs
26 compiler is used to compile against the Silverlight/Moonlight profile.
27 This profile is designed to be used for creating Silverlight/Moonlight
28 applications that will run on a web browser.   The API exposed by this
29 profile is a small subset of the 2.0 API (even if it is commonly
30 referred as the 2.1 API, this API is a small subset of 2.0 with a few
31 extensions), in addition this profile by default runs with
32 -langversion:linq which turns on the C# 3.0 language by default.
33 .PP
34 The Mono C# compiler accepts the same command line options that the
35 Microsoft C# compiler does.  Those options can start with a slash or a
36 dash (/checked is the same as -checked).  Additionally some GNU-like
37 options are supported, those begin with "--".  All MCS-specific flags
38 which are not available in the Microsoft C# compiler are available
39 only with the GNU-style options.
40 .PP
41 C# source files must end with a ".cs" extension.  Compilation of C#
42 source code requires all the files that make up a library, module or
43 executable to be provided on the command line.  There is no support
44 for partial compilation.  To achieve the benefits of partial
45 compilation, you should compile programs into their own assemblies,
46 and later reference them with the "-r" flag.
47 .PP
48 The Mono C# compiler generates images (.exe files) that contain CIL
49 byte code that can be executed by any system that implements a Common
50 Language Infrastructure virtual machine such as the Microsoft .NET
51 runtime engine on Windows or the Mono runtime engine on Unix systems.
52 Executables are not bound to a specific CPU or operating system.
53 .PP
54 The Mono C# compiler by default only references three assemblies:
55 mscorlib.dll, System.dll and System.Xml.dll.   If you want to
56 reference extra libraries you must manually specify them using the
57 -pkg: command line option or the -r: command line option.
58 Alternatively if you want to get all of the System libraries, you can
59 use the -pkg:dotnet command line option.
60 .PP
61 .SH OPTIONS
62 .TP
63 .I \-\-about
64 Displays information about the Mono C# compiler
65 .TP
66 .I \-\-addmodule:MODULE1[,MODULE2]
67 Includes the specified modules in the resulting assembly.  
68 .TP
69 .I -checked, -checked+
70 Sets the default compilation mode to `checked'.  This makes all
71 the math operations checked (the default is unchecked).
72 .TP
73 .I -checked-
74 Sets the default compilation mode to `unchecked'.  This makes all
75 the math operations unchecked (this is the default).
76 .TP
77 .I -codepage:ID
78 Specifies the code page used to process the input files from the
79 point it is specified on.  By default files will be processed in the
80 environment-dependent native code page.  The compiler will also automatically
81 detect Unicode files that have an embedded byte mark at the beginning.   
82 .Sp
83 Other popular encodings are 28591 (Latin1), 1252 (iso-8859-1) and 65001 (UTF-8).
84 .Sp
85 MCS supports a couple of shorthands: "utf8" can be used to specify utf-8 instead
86 of using the cryptic 65001 and "reset" restores the automatic handling of
87 code pages.  These shorthands are not available on the Microsoft compiler.
88 .TP
89 .I \-define:SYMLIST, -d:SYMLIST
90 Defines the symbol listed by the semi-colon separated list SYMLIST
91 SYMBOL.  This can be tested in the source code by the pre-processor,
92 or can be used by methods that have been tagged with the Conditional
93 attribute. 
94 .TP
95 .I \-debug, \-debug+, \-g
96 Generate debugging information.  To obtain stack traces with debugging
97 information, you need to invoke the mono runtime with the `--debug'
98 flag.  This debugging information is stored inside the assembly as a
99 resource.
101 .I \-debug-
102 Do not generate debugging information.
104 .I \-delaysign+
105 Only embed the strongname public key into the assembly. The actual 
106 signing must be done in a later stage using the SN tool. This is useful
107 to protect the private key during development. Note that delay signing
108 can only be done using a strongname key file (not a key container). The
109 option is equivalent to including [assembly: AssemblyDelaySign (true)] 
110 in your source code. Compiler option takes precedence over the 
111 attributes.
113 .I \-delaysign-
114 Default. Strongname (sign) the assembly using the strong name key file
115 (or container). The option is equivalent to including [assembly: 
116 AssemblyDelaySign (false)] in your source code. Compiler option takes
117 precedence over the attributes.
119 .I \-doc:FILE
120 Extracts the C#/XML documentation from the source code and stores in in
121 the given FILE.
123 .I \-\-expect-error X L
124 The compiler will expect the code to generate an error 
125 named `X' in line `L'.  This is only used by the test suite.
126 .TP 
127 .I \-\-fatal 
128 This is used for debugging the compiler.  This makes the error emission
129 generate an exception that can be caught by a debugger.
131 .I \-keyfile:KEYFILE
132 Strongname (sign) the output assembly using the key pair present in 
133 the specified strong name key file (snk). A full key pair is required
134 by default (or when using delaysign-). A file containing only the
135 public key can be used with delaysign+. The option is equivalent to 
136 including [assembly: AssemblyKeyFile ("KEYFILE")] in your source code.
137 Compiler option takes precedence over the attributes.
139 .I \-keycontainer:CONTAINER
140 Strongname (sign) the output assembly using the key pair present in 
141 the specified container. Note that delaysign+ is ignored when using 
142 key containers. The option is equivalent to including [assembly: 
143 AssemblyKeyName ("CONTAINER")] in your source code. Compiler option 
144 takes precedence over the attributes.
146 .I \-langversion:TEXT
147 The option specifies the version of the language to use. The feature
148 set is different in each C# version. This switch can be used to force
149 the compiler to allow only a subset of the features.
150 The possible values are:
152 .ne 8
154 .I "Default"
155 Instruct compiler to use the latest version. Equivalent is to omit the
156 switch (this currently defaults to the C# 2.0 language specification).
158 .I "ISO-1"
159 Restrict compiler to use only first ISO standardized features.
160 The usage of features such as generics, static classes, anonymous
161 methods will lead to error.
163 .I "ISO-2"
164 Restrict compiler to use only the second ISO standardized features.
165 This allows the use of generics, static classes, iterators and
166 anonymous methods for example.
168 .I "linq"
169 This enables the C# 3.0 support.   Only a few features of C# 3.0 have
170 been implemented in the Mono C# compiler, so not everything is
171 available. 
173 Notice that this flag only controls the language features available to
174 the programmer, it does not control the kind of assemblies produced.
175 Programs compiled with mcs will reference the 1.1 APIs, Programs
176 compiled with gmcs reference the 2.0 APIs.
180 .I -lib:PATHLIST
181 Each path specified in the comma-separated list will direct the
182 compiler to look for libraries in that specified path.
184 .I \-L PATH
185 Directs the compiler to look for libraries in the specified path.
186 Multiple paths can be provided by using the option multiple times.
188 .I \-main:CLASS
189 Tells the compiler which CLASS contains the entry point. Useful when
190 you are compiling several classes with a Main method.
192 .I \-nostdlib, -nostdlib+
193 Use this flag if you want to compile the core library.  This makes the
194 compiler load its internal types from the assembly being compiled.
196 .I \-noconfig, \-noconfig+
197 Disables the default compiler configuration to be loaded.  The
198 compiler by default has references to the system assemblies. 
200 .I \-nowarn:WARNLIST
201 Makes the compiler ignore warnings specified in the comma-separated
202 list WARNLIST>
204 .I -optimize, -optimize+, -optimize-
205 Controls whether to perform optimizations on the code.   -optimize and
206 -optimize+ will turn on optimizations, -optimize- will turn it off.
207 The default in mcs is to optimize+.
209 .I -out:FNAME, -o FNAME
210 Names the output file to be generated.
212 .I \-\-parse
213 Used for benchmarking.  The compiler will only parse its input files.
215 .I \-pkg:package1[,packageN]
216 Reference assemblies for the given packages.
218 The compiler will invoke pkg-config --libs on the set of packages
219 specified on the command line to obtain libraries and directories to
220 compile the code.
222 This is typically used with third party components, like this:
225                 $ mcs -pkg:gtk-sharp demo.cs
228 .ne 8
230 .I \-pkg:dotnet
231 This will instruct the compiler to reference the System.* libraries
232 available on a typical dotnet framework installation, notice that this
233 does not include all of the Mono libraries, only the System.* ones.  This
234 is a convenient shortcut for those porting code.
236 .I \-pkg:olive
237 Use this to reference the "Olive" libraries (the 3.0 and 3.5 extended
238 libraries).
240 .I \-pkg:silver
241 References the assemblies for creating Moonlight/Silverlight
242 applications.  This is automatically used when using the 
243 .I smcs 
244 compiler, but it is here when developers want to use it with the
245 .I gmcs
246 compiler.
248 .I \-pkg:silverdesktop
249 Use this option to create Moonlight/Silverlight applications that
250 target the desktop.   This option allows developers to consume the
251 Silverlight APIs with the full 2.0 profile API available to them,
252 unlike 
253 .I smcs 
254 it gives full access to all the APIs that are part of Mono.  The only
255 downside is that applications created with silverdesktop will not run
256 on the browser.   Typically these applications will be launched
257 with the 
258 .I mopen
259 command line tool.
263 .I -resource:RESOURCE[,ID]
264 Embeds to the given resource file.  The optional ID can be used to
265 give a different name to the resource.  If not specified, the resource
266 name will be the file name.
268 .I -linkresource:RESOURCE[,ID]
269 Links to the specified RESOURCE.  The optional ID can be used to give
270 a name to the linked resource.
272 .I -r:ASSEMBLY1[,ASSEMBLY2], \-r ASSEMBLY1[,ASSEMBLY2]
273 Reference the named assemblies.  Use this to use classes from the named
274 assembly in your program.  The assembly will be loaded from either the
275 system directory where all the assemblies live, or from the path
276 explicitly given with the -L option.
278 You can also use a semicolon to separate the assemblies instead of a
279 comma. 
281 .I \-recurse:PATTERN, --recurse PATTERN
282 Does recursive compilation using the specified pattern.  In Unix the
283 shell will perform globbing, so you might want to use it like this:
286                 $ mcs -recurse:'*.cs' 
289 .I \-\-stacktrace
290 Generates a stack trace at the time the error is reported, useful for
291 debugging the compiler.
293 .I \-target:KIND, \-t:KIND
294 Used to specify the desired target.  The possible values are: exe
295 (plain executable), winexe (Windows.Forms executable), library
296 (component libraries) and module (partial library).
298 .I \-\-timestamp
299 Another debugging flag.  Used to display the times at various points
300 in the compilation process.
302 .I \-unsafe, -unsafe+
303 Enables compilation of unsafe code.
305 .I \-v 
306 Debugging. Turns on verbose yacc parsing.
308 .I \-v2
309 Turns on C# 2.0 language features.
311 .I \-\-version
312 Shows the compiler version.
314 .I \-warnaserror, \-warnaserror+
315 Treat warnings as errors.
317 .I \-warn:LEVEL
318 Sets the warning level.  0 is the lowest warning level, and 4 is the
319 highest.  The default is 2.
321 .I \-win32res:FILE
322 Specifies a Win32 resource file (.res) to be bundled into the
323 resulting assembly.
325 .I \-win32icon:FILE
326 Attaches the icon specified in FILE on the output into the resulting
327 assembly.
329 .I \-\-
330 Use this to stop option parsing, and allow option-looking parameters
331 to be passed on the command line.
333 .SH SPECIAL DEFINES
334 The 
335 .B TRACE
337 .B DEBUG
338 defines have a special meaning to the compiler.
340 By default calls to methods and properties in the
341 System.Diagnostics.Trace class are not generated unless the TRACE
342 symbol is defined (either through a "#define TRACE") in your source
343 code, or by using the
344 .I "--define TRACE"
345 in the command line.
347 By default calls to methods and properties in the
348 System.Diagnostics.Debug class are not generated unless the DEBUG
349 symbol is defined (either through a "#define DEBUG") in your source
350 code, or by using the
351 .I "--define DEBUG"
352 in the command line.
354 Note that the effect of defining TRACE and DEBUG is a global setting,
355 even if they are only defined in a single file.
357 .SH DEBUGGING SUPPORT
358 When using the "-debug" flag, MCS will generate a file with the
359 extension .mdb that contains the debugging information for the
360 generated assembly.  This file is consumed by the Mono debugger (mdb).
361 .SH ENVIRONMENT VARIABLES
363 .I "MCS_COLORS"
364 If this variable is set, it contains a string in the form
365 "foreground,background" that specifies which color to use to display
366 errors on some terminals.  
368 The background is optional and defaults to your terminal current
369 background.   The possible colors for foreground are:
370 .B black, red, brightred, green, brightgreen, yellow, brightyellow,
371 blue, brightblue, magenta, brightmagenta, cyan, brightcyan, grey,
372 white and brightwhite.
374 The possible colors for background are: black, red, green, yellow,
375 blue, magenta, cyan, grey and white.
376 .Sp 
377 For example, you could set these variable from your shell:
379         export MCS_COLORS
380         MCS_COLORS=errors=brightwhite,red
383 You can disable the built-in color scheme by setting this variable to
384 "disable".
385 .SH NOTES
386 During compilation the MCS compiler defines the __MonoCS__ symbol,
387 this can be used by pre-processor instructions to compile Mono C#
388 compiler specific code.   Please note that this symbol is only to test
389 for the compiler, and is not useful to distinguish compilation or
390 deployment platforms.  
391 .SH AUTHORS
392 The Mono C# Compiler was written by Miguel de Icaza, Ravi Pratap,
393 Martin Baulig, Marek Safar and Raja Harinath.  The development was
394 funded by Ximian, Novell and Marek Safar.
396 .SH LICENSE
397 The Mono Compiler Suite is released under the terms of the GNU GPL.
398 Please read the accompanying `COPYING' file for details.  Alternative
399 licensing for the compiler is available from Novell.
401 .SH SEE ALSO
402 mdb(1), mono(1), mopen(1), mint(1), sn(1)
404 .SH BUGS
405 To report bugs in the compiler, you must file them on our bug tracking
406 system, at:
407 http://www.mono-project.com/Bugs 
408 .SH MAILING LIST
409 The Mono Mailing lists are listed at http://www.mono-project.com/Mailing_Lists
410 .SH MORE INFORMATION
411 The Mono C# compiler was developed by Novell, Inc
412 (http://www.novell.com, http) and is based on the
413 ECMA C# language standard available here:
414 http://www.ecma.ch/ecma1/STAND/ecma-334.htm
416 The home page for the Mono C# compiler is at http://www.mono-project.com/CSharp_Compiler