New test.
[mono.git] / man / mcs.1
1 .TH mcs 1 "6 January 2001"
2 .SH NAME 
3 mcs, gmcs \- Mono Compiler Suite.
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.  The
18 .I gmcs
19 compiler is used to compile against the 2.x profile and implements
20 the complete C# 2.0 specification.
21 .PP
22 The Mono C# compiler accepts the same options than the Microsoft C#
23 compiler does.  Those options can start with a slash or a dash
24 (/checked is the same as -checked).  Additionally to this, the
25 GNU-like options are supported, those begin with "--".  All
26 MCS-specific flags which are not available in the Microsoft C#
27 compiler are available only with the GNU-style options. 
28 .PP
29 C# source files must end with a ".cs" extension.  Compilation of C#
30 source code requires all the files that make up a library, module or
31 executable to be provided on the command line.  There is no support
32 for partial compilation.  To achieve the benefits of partial
33 compilation, you should compile programs into their own assemblies,
34 and later reference them with the "-r" flag.
35 .PP
36 The Mono C# compiler generates images (.exe files) that contain CIL
37 byte code that can be executed by any system that implements a Common
38 Language Infrastructure virtual machine such as the Microsoft .NET
39 runtime engine on Windows or the Mono runtime engine on Unix systems.
40 Executables are not bound to a specific CPU or operating system.
41 .PP
42 The Mono C# compiler by default only references three assemblies:
43 mscorlib.dll, System.dll and System.Xml.dll.   If you want to
44 reference extra libraries you must manually specify them using the
45 -pkg: command line option or the -r: command line option.
46 Alternatively if you want to get all of the System libraries, you can
47 use the -pkg:dotnet command line option.
48 .PP
49 .SH OPTIONS
50 .TP
51 .I \-\-about
52 Displays information about the Mono C# compiler
53 .TP
54 .I \-\-addmodule:MODULE1[,MODULE2]
55 Includes the specified modules in the resulting assembly.  
56 .TP
57 .I -checked, -checked+
58 Sets the default compilation mode to `checked'.  This makes all
59 the math operations checked (the default is unchecked).
60 .TP
61 .I -checked-
62 Sets the default compilation mode to `unchecked'.  This makes all
63 the math operations unchecked (this is the default).
64 .TP
65 .I -codepage:ID
66 Specifies the code page used to process the input files from the
67 point it is specified on.  By default files will be processed in the
68 Latin-1 code page.  The compiler will also automatically detect
69 Unicode files that have an embedded byte mark at the beginning.   
70 .TP
71 Other popular encodings are 28591 (Latin1), 1252 (iso-8859-1) and 65001 (UTF-8).
72 .TP 
73 MCS supports a couple of shorthands: "utf8" can be used to specify utf-8 instead
74 of using the cryptic 65001 and "reset" restores the automatic handling of
75 code pages.  These shorthands are not available on the Microsoft compiler.
76 .TP
77 .I \-define:SYMLIST, -d:SYMLIST
78 Defines the symbol listed by the semi-colon separeted list SYMLIST
79 SYMBOL.  This can be tested in the source code by the pre-processor,
80 or can be used by methods that have been tagged with the Conditional
81 attribute. 
82 .TP
83 .I \-debug, \-debug+, \-g
84 Generate debugging information.  To obtain stack traces with debugging
85 information, you need to invoke the mono runtime with the `--debug'
86 flag.  This debugging information is stored inside the assembly as a
87 resource.
88 .TP
89 .I \-debug-
90 Do not generate debugging information.
91 .TP
92 .I \-delaysign+
93 Only embed the strongname public key into the assembly. The actual 
94 signing must be done in a later stage using the SN tool. This is useful
95 to protect the private key during development. Note that delay signing
96 can only be done using a strongname key file (not a key container). The
97 option is equivalent to including [assembly: AssemblyDelaySign (true)] 
98 in your source code. Compiler option takes precedence over the 
99 attributes.
100 .TP
101 .I \-delaysign-
102 Default. Strongname (sign) the assembly using the strong name key file
103 (or container). The option is equivalent to including [assembly: 
104 AssemblyDelaySign (false)] in your source code. Compiler option takes
105 precedence over the attributes.
106 .TP
107 .I \-doc:FILE
108 Extracts the C#/XML documentation from the source code and stores in in
109 the given FILE.
110 .TP
111 .I \-\-expect-error X L
112 The compiler will expect the code to generate an error 
113 named `X' in line `L'.  This is only used by the test suite.
114 .TP 
115 .I \-\-fatal 
116 This is used for debugging the compiler.  This makes the error emission
117 generate an exception that can be caught by a debugger.
118 .TP
119 .I \-keyfile:KEYFILE
120 Strongname (sign) the output assembly using the key pair present in 
121 the specified strong name key file (snk). A full key pair is required
122 by default (or when using delaysign-). A file containing only the
123 public key can be used with delaysign+. The option is equivalent to 
124 including [assembly: AssemblyKeyFile ("KEYFILE")] in your source code.
125 Compiler option takes precedence over the attributes.
126 .TP
127 .I \-keycontainer:CONTAINER
128 Strongname (sign) the output assembly using the key pair present in 
129 the specified container. Note that delaysign+ is ignored when using 
130 key containers. The option is equivalent to including [assembly: 
131 AssemblyKeyName ("CONTAINER")] in your source code. Compiler option 
132 takes precedence over the attributes.
133 .TP
134 .I \-langversion:TEXT
135 The option specifies the version of the language to use. The feature
136 set is different in each C# version. This switch can be used to force
137 the compiler to allow only a subset of the features.
138 The possible values are:
139 .nf
140
141 Default - Instruct compiler to use the latest version. Equivalent
142 is to omit the switch.
143
144 ISO-1   - Restrict compiler to use only ISO standardized features.
145 The usage of features such as generics, static classes, anonymous
146 methods will lead to error.
147 .Sp
148 Notice that this flag only controls the language features available to
149 the programmer, it does not control the kind of assemblies produced.
150 Programs compiled with mcs will reference the 1.1 APIs, Programs
151 compiled with gmcs reference the 2.0 APIs.
152 .TP
153 .I -lib:PATHLIST
154 Each path specified in the comma-separated list will direct the
155 compiler to look for libraries in that specified path.
156 .TP
157 .I \-L PATH
158 Directs the compiler to look for libraries in the specified path.
159 Multiple paths can be provided by using the option multiple times.
160 .TP
161 .I \-main:CLASS
162 Tells the compiler which CLASS contains the entry point. Useful when
163 you are compiling several classes with a Main method.
164 .TP
165 .I \-nostdlib, -nostdlib+
166 Use this flag if you want to compile the core library.  This makes the
167 compiler load its internal types from the assembly being compiled.
168 .TP
169 .I \-noconfig, \-noconfig+
170 Disables the default compiler configuration to be loaded.  The
171 compiler by default has references to the system assemblies. 
172 .TP
173 .I \-nowarn:WARNLIST
174 Makes the compiler ignore warnings specified in the comma-separeted
175 list WARNLIST>
176 .TP
177 .I -optimize, -optimize+, -optimize-
178 Controls whether to perform optimizations on the code.   -optimize and
179 -optimize+ will turn on optimizations, -optimize- will turn it off.
180 The default in mcs is to optimize+.
181 .TP
182 .I -out:FNAME, -o FNAME
183 Names the output file to be generated.
184 .TP
185 .I \-\-parse
186 Used for benchmarking.  The compiler will only parse its input files.
187 .TP
188 .I \-pkg:package1[,packageN]
189 The compiler will invoke pkg-config --libs on the set of packages
190 specified on the command line to obtain libraries and directories to
191 compile the code.
192 .PP
193 This is typically used with third party components, like this:
194 .nf
195                 $ mcs -pkg:gtk-sharp demo.cs
196 .fi
197 .TP
198 .TP
199 .I \-pkg:dotnet
200 This will instruct the compiler to reference the System.* libraries
201 available on a typical dotnet framework installation, notice that this
202 does not include all of the Mono libraies, only the System.* ones.  This
203 is a convenient shortcut for those porting code.
204 .TP
205 .I -resource:RESOURCE[,ID]
206 Embeds to the given resource file.  The optional ID can be used to
207 give a different name to the resource.  If not specified, the resource
208 name will be the file name.
209 .TP
210 .I -linkresource:RESOURCE[,ID]
211 Links to the specified RESOURCE.  The optional ID can be used to give
212 a name to the linked resource.
213 .TP
214 .I -r:ASSEMBLY1[,ASSEMBLY2], \-r ASSEMBLY1[,ASSEMBLY2]
215 Reference the named assemblies.  Use this to use classes from the named
216 assembly in your program.  The assembly will be loaded from either the
217 system directory where all the assemblies live, or from the path
218 explicitly given with the -L option.
219 .PP
220 You can also use a semicolon to separate the assemblies instead of a
221 comma. 
222 .TP
223 .I \-recurse:PATTERN, --recurse PATTERN
224 Does recursive compilation using the specified pattern.  In Unix the
225 shell will perform globbing, so you migth want to use it like this:
226 .PP
227 .nf
228                 $ mcs -recurse:'*.cs' 
229 .fi
230 .TP
231 .I \-\-stacktrace
232 Generates a stack trace at the time the error is reported, useful for
233 debugging the compiler.
234 .TP
235 .I \-target:KIND, \-t:KIND
236 Used to specify the desired target.  The possible values are: exe
237 (plain executable), winexe (Windows.Forms executable), library
238 (component libraries) and module (partial library).
239 .TP
240 .I \-\-timestamp
241 Another debugging flag.  Used to display the times at various points
242 in the compilation process.
243 .TP
244 .I \-unsafe, -unsafe+
245 Enables compilation of unsafe code.
246 .TP
247 .I \-v 
248 Debugging. Turns on verbose yacc parsing.
249 .TP
250 .I \-v2
251 Turns on C# 2.0 language features.
252 .TP
253 .I \-\-version
254 Shows the compiler version.
255 .TP
256 .I \-warnaserror, \-warnaserror+
257 Treat warnings as errors.
258 .TP
259 .I \-warn:LEVEL
260 Sets the warning level.  0 is the lowest warning level, and 4 is the
261 highest.  The default is 2.
262 .TP
263 .I \-win32res:FILE
264 Specifies a Win32 resource file (.res) to be bundled into the
265 resulting assembly.
266 .TP
267 .I \-win32icon:FILE
268 Attaches the icon specified in FILE on the output into the resulting
269 assembly.
270 .TP
271 .I \-\-
272 Use this to stop option parsing, and allow option-looking parameters
273 to be passed on the command line.
274 .PP
275 .SH SPECIAL DEFINES
276 The 
277 .B TRACE
278 and
279 .B DEBUG
280 defines have a special meaning to the compiler.
281 .PP
282 By default calls to methods and properties in the
283 System.Diagnostics.Trace class are not generated unless the TRACE
284 symbol is defined (either through a "#define TRACE") in your source
285 code, or by using the
286 .I "--define TRACE"
287 in the command line.
288 .PP
289 By default calls to methods and properties in the
290 System.Diagnostics.Debug class are not generated unless the DEBUG
291 symbol is defined (either through a "#define DEBUG") in your source
292 code, or by using the
293 .I "--define DEBUG"
294 in the command line.
295 .PP
296 Note that the effect of defining TRACE and DEBUG is a global setting,
297 even if they are only defined in a single file.
298 .PP
299 .SH DEBUGGING SUPPORT
300 When use the "--debug" or "-g" flag, MCS will create an assembler file
301 FILE-debug.s containing debugging information where FILE is the name of
302 the generated assembly. You need to run this file through the assembler
303 to get a object file FILE-debug.o.  See mono's "--dwarf-plus" argument
304 for details on how to use this file.
305 .SH NOTES
306 During compilation the MCS compiler defines the __MonoCS__ symbol,
307 this can be used by pre-processor instructions to compile Mono C#
308 compiler specific code.   Please note that this symbol is only to test
309 for the compiler, and is not useful to distinguish compilation or
310 deployment platforms.
311 .SH AUTHORS
312 The Mono C# Compiler was written by Miguel de Icaza, Ravi Pratap and
313 Martin Baulig at Ximian.
314 .PP
315 .SH LICENSE
316 The Mono Compiler Suite is released under the terms of the GNU GPL.
317 Please read the accompanying `COPYING' file for details.  Alternative
318 licenses are available from Ximian.
319 .PP
320 .SH SEE ALSO
321 mono(1), mint(1), sn(1)
322 .PP
323 .SH BUGS
324 To report bugs in the compiler, you can use `bug-buddy', or you can
325 file bug reports in our bug tracking system:
326 http://bugzilla.ximian.com.
327 .SH MAILING LIST
328 The Mono Mailing List is available at: mono-list-request@ximian.com
329 .SH MORE INFORMATION
330 The Mono C# compiler is developed by Ximian, Inc
331 (http://www.ximian.com) (http://www.ximian.com) and is based on the
332 ECMA C# language standard available here:
333 http://www.ecma.ch/ecma1/STAND/ecma-334.htm
334
335