Compiler Options

 
Appendix B - C# Compilation Options
bySimon Robinsonet al.
Wrox Press 2002
  

The first table shows the various file formats that can be output by the compiler:

Option

Purpose

/doc: < filename >

Processes XML documentation comments ( marked with three slashes , /// ) and outputs to the specified XML file.

/nooutput

Compiles code but does not create an output file; useful for debugging purposes as the console will show warnings and errors.

/out: < filename >

Specifies the name of the output file. If this is not specified the compiler generates a standard .exe file with the same name as the source file (minus the extension).

/target: < option > /t: < option >

Specifies the format of the output file. The four options are: exe : produces a standard executable (the default setting).

library : produces a code library (DLL).

module : produces a code module (assembly with no manifest), which is later added to an assembly (using / addmodule ).

winexe : creates a Windows executable.

Unless the /target:module option is specified the compiler will add a manifest to the EXE that is created (or the first DLL if no EXE is created). Note that /target can be abbreviated to /t .

The next table explains the command-line option for determining compiler optimizations.

Option

Purpose

/optimize < + - > /o < + - >

Enables or disables optimizations carried out by the compiler to produce smaller, faster, and more efficient output. This is disabled by default. To enable, use the syntax: /optimize or /optimize+ To disable, use this syntax: /optimize-

The following table describes options that are used when creating and referring to .NET assemblies:

Option

Purpose

/addmodule: < module >

Specifies one or more modules to be included in the specified assembly. If more than one module is specified, they are separated by semicolons. This option is not available in Visual Studio .NET.

/nostdlib < + - >

Specifies whether or not to import the standard library ( mscorlib.dll ), which is imported by default.

If you want to implement your own System namespace and classes, you may want the compiler not to load the standard library. The syntax for doing this is: /nostdlib or /nostdlib+ The syntax for importing it is: /nostdlib-

/reference: < assembly > /r: < assembly >

Imports metadata from an assembly file. You can specify the full path to the assembly, or anywhere specified by the PATH environment variable, or a relative path starting at the current project. If more than one file is specified, they are separated by semicolons.

The following table explains the options that apply to debugging and error checking:

Option

Purpose

/bugreport: < filename >

Creates the specified file that contains any bug information produced by the compiler. The contents of the file include:

  • A copy of all sourcecode

  • A listing of compiler options

  • Information on the compiler version, operating system etc.

  • Any compiler output

  • Description of problem and possible solution (optional)

This option is not available in Visual Studio .NET

/checked < + - >

Specifies whether integer overflows raise a run-time error. This applies only to code outside of the scope of checked and unchecked blocks. This is disabled by default. The syntax for overflow checking is: /checked or /checked+ To disable overflow checking use this syntax: /checked-

/debug < + - > /debug: < option >

Generates debugging information. To enable this use the syntax: /debug or /debug+ To disable use this: /debug- Debugging is disabled by default. If you specify that debugging information should be output, then you have two options regarding the type of debugging information that is produced: /debug:full : enables the attaching of a debugger to the operating program.

/debug:pdbonly : allows sourcecode debugging when the program is started in the debugger but will only display assembler when the running program is attached to the debugger.

/fullpaths

Specifies the full path to the file containing the error. This option is not available in Visual Studio .NET.

/nowarn: < number >

Suppresses the compiler's ability to generate specified warnings. The < number > option specifies which warning number to suppress. If more than one is specified, they are separated by commas. This option is not available in Visual Studio .NET.

/warn: < option > /w: < option >

Sets the minimum warning level that you want to display. The options are:

: suppresses all warnings

1 : displays only severe warnings

2 : displays severe warnings plus warnings of medium severity

3 : displays severe warnings plus warnings of medium and low severity

4 : displays all warnings including informational warnings

/warnaserror < + - >

Treats all warnings as errors. To enable, this use this syntax: /warnaserror or /warnaserror+ To disable use this syntax: /warnaserror- This is disabled by default.

This table show how to set preprocessor directives:

Option

Purpose

/define: < name > /d: < name >

Defines preprocessor symbol specified by < name >

This table explains the options associated with including external resources:

Option

Purpose

/linkresource: < filename >

/linkres:<filename>

Creates a link to the specified .NET resource. Two optional additional parameters (delimited by commas) are:

identifier : the logical name for the resource; the name used to load the resource (the default is the filename)

mimetype : a string representing the media type for the resource (the default is none)

This option is not available in Visual Studio .NET.

/resource: < filename > /res: < filename >

Embeds a .NET-specified resource into the output file. Two optional additional parameters (delimited by commas) are:

identifier : the logical name for the resource; the name used to load the resource (the default is the filename).

mimetype : a string representing the media type for the resource (the default is none).

/win32icon: < filename >

Inserts the specified Win32 icon ( .ico ) file into the output file.

/win32res: < filename >

Inserts the specified Win32 resource ( .res ) file into the output file. This option is not available in Visual Studio .NET.

The final table lists various miscellaneous compiler options:

Option

Purpose

@ < filename >

Specifies a file that contains all the compiler options and source files that will be processed by the compiler as if they had been entered at the command line.

/baseaddress: < address >

Specifies the preferred base address at which to load a DLL. The value of < address > can be decimal, hexadecimal, or octal.

/codepage: < id >

Specifies the code page (value passed as the < id > option) to use for all sourcecode files in the compilation. Use this option if you use a character set in the C# files which isn't the default for your system. This option is not available in Visual Studio .NET.

/help/?

Lists compiler options to standard output. This option is not available in Visual Studio .NET.

/incremental < + - > /incr < + - >

Allows incremental compilation of sourcecode files, that is, it compiles only those functions that have been altered since the previous compilation. Information about the state of the previous compilation is stored in two files, a .dbg file (or .pdb if /debug has been specified) to hold debug information and a .incr file to hold state information. To enable this use either syntax: /incremental or /incremental+ To disable use this syntax:

/incremental- This is disabled by default.

/main: < class >

Specifies the location of the Main() method, if more than one exists in the sourcecode.

/nologo

Suppresses the output of the compiler banner information. This option is not available in Visual Studio .NET.

/recurse: < dir\file >

Searches subdirectories for source files to compile. There are two options:

dir (optional): the directory or subdirectory to start the search from. If not specified, it is the directory of the current project.

file : the file or files to search for. You can use wildcards.

/unsafe

Allows the compilation of code that uses the unsafe keyword.

  


Professional C#. 2nd Edition
Performance Consulting: A Practical Guide for HR and Learning Professionals
ISBN: 1576754359
EAN: 2147483647
Year: 2002
Pages: 244

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net