sc { { @responsefile } { file } { switches } }where the { } means "repeated 0 or more times". SC with no arguments prints a short help file to stdout.
;Comments are lines where the first non-blank character ; is a ';' [Environment] INCLUDE=c:\sc\bin LIB=c:\sc\lib CFLAGS=-v -w ;Note that %PATH% gets replaced by the previous value of ; the environment variable PATH. PATH=c:\sc\bin;%PATH%The special environment variable @P gets replaced with the path to where the sc.ini file resides. For instance, the above can be replaced with (if sc.ini is in c:\sc\bin):
[Environment] INCLUDE=%@P%..\BIN LIB=%@P%..\LIB CFLAGS=-v -w PATH=%@P%..\BIN;%PATH%which makes the settings in sc.ini independent of where the SC directory tree is installed.
If sc.ini is not there, no error results. This feature is useful for avoiding cluttering up AUTOEXEC.BAT with environment variable settings. Not only that, it will make running SC independent of any existing environment variables set for other tools.
The environment settings in sc.ini do not prefix, augment, or append any existing settings in the environment. They replace the environment settings for the duration of running the IDDE or the compiler. If you wish, for example, to use sc.ini to append an INCLUDE path to the existing INCLUDE path, it can be written as:
[Environment] INCLUDE=%INCLUDE%;C:\SC\INCLUDE
.c .cpp .cxx .cc .c++ .asm .s .rcThe extension of the file determines what is done with the file.
no extension any other extension .c Run C compiler .cpp .cxx .cc .c++ Run C++ compiler .asm .s Run assembler .lib .a Include file as a library to the linker .obj .o Include file as an object file to the linker .exe .com .sys .dll Include file as the output file to the linker .def Include file as the module definition file to the linker .rc Run resource compiler .res Include file as the resource file to linker
Alignment can also be controlled within a source file by using #pragma pack().
Effects on C and C++:
Effects on C:
Effects on C++:
char abc[4] = "1234";
where there is no room for the trailing 0 is invalid.
Because code generated for exception handling (EH) is not quite as good ('this' pointers are not placed in registers, tables are generated), the default is that EH is not enabled. To enable EH, compile with the -Ae switch. Compiling for ANSI C++ (-A) will also enable exception handling support.
To compile C code that is to be mixed into C++ code that handles exceptions, compile the C code with -Ae also.
Objects compiled with -Ae may be linked with objects compiled without -Ae, provided that no exceptions are thrown in the resulting program that are not handled entirely within objects compiled with -Ae.
The tables are generated in the same segment using the same rules as the virtual function pointer tables. Using -NV will place the tables in far segments (for 16 bit memory models).
For link compatibility with Microsoft C++ compiled DLLs, but still using RTTI, compile with -ER:
Virtual function call compatibility is not affected by RTTI.
It is best to avoid using RTTI on classes that are pulled in from a .LIB, .OBJ or .DLL where they were compiled with a different compiler.
-C Disable inline function expansion -C- (default) enable inline expansion -C prevents the inline expansion of functions with the inline storage class. This can be useful in sorting out a complex tangle if inlined functions when debugging. It can also result in smaller (but slower) generated executables. -C suppresses the production of inline code and causes functions declared as inline or __inline to be treated as static (non-member) functions. -C has no effect on compiler intrinsic functions like strcmp() and memcpy(). If these functions should not be inlined, use the portable method: #undef strcmp /* use runtime library version of strcmp */ -cod Generate .cod (assembler output) file This causes OBJ2ASM to be run on the .obj file output from the compiler to generate a .cod file showing the assembly code generated by the compiler. Using this along with the -gl switch will generate a mixed source/assembly .cod file. -d Generate dependency information If file.c is being compiled, then file.dep will be created. It will contain a list of #include files that file.obj depends on. So, the line in the makefile can be written as: file.obj : $(file.dep) file.c sc -c file -d -D[macro[=text]] define macro -D Equivalent to #define DEBUG 1 Will also enable the debug statements and debug declarations. -Dmacro Equivalent to #define macro 1 -Dmacro= Equivalent to #define macro -Dmacro=text Equivalent to #define macro text The '#' character can be used instead of '='. To embed white space in the macro's text, enclose the entire macro value in double ("") or single quotation marks (''), as in -Dmacro="this is a string", which is equivalent to #define macro "this is a string". -e show results of preprocessor Shows the effects of the preprocessor in error messages and in the list file. To verify that macros are expanding as expected, use the options -e and -l together. -EC do not elide comments For SPP: leave comments in preprocessed output. -EH obsolete - use -Ae -EL #line directives not output For SPP: do not add #line directives into the output. -ER obsolete - use -Ar -f generate IEEE 754 inline 8087 code For 16 bit code and the DOSX memory model, the compiler by default generates code assuming a numeric coprocessor does not exist. This code is less efficient than if numeric coprocessor code is generated directly. -f will cause numeric coprocessor code to be generated directly, but the code will not run on machines without a coprocessor. Win32 implementations have an emulator for the numeric coprocessor, so -f is the default for the -mn memory model. -fd generate IEEE 754 inline 8087 code with workaround for FDIV bug Some old Pentium CPU chips have a bug when executing FDIV instructions. When not generating inline 8087 code, the floating point emulator in the runtime library automatically accounts and corrects for the errors. When generating inline 8087 code, the -fd switch will call a runtime library function for FDIV instead of generating an FDIV instruction directly. This results in code that is a little larger and slower than -f code, but it won't be subject to FDIV bugs. Do not use -fd if your code will never be run on a Pentium. No Pentium Pro or Pentium MMX chips have this bug. -ff fast inline 8087 code The difference between -f and -ff is that with -ff floating point comparisons with NaN (Not a Number) are not done exactly according to IEEE 754. Normally, this does not matter, so -ff will yield faster code. Other compilers for Intel CPUs do not correctly generate code for NaN comparisons, so to compare Digital Mars floating point code performance with that of other compilers, use the -ff switch.-ff will also cause the folding of floating point constants even if they would generate an exception. For example, 0.0/0.0 will be folded at compile time instead of at runtime.
Use -ff -fd in combination to get fast inline code with the FDIV bug workaround. -g{-345dfghlpst} generate debug info There are several ways of generating debug info for a compiled file. If the compiler always generated debug info for all types, the .OBJ files would be huge and the linker would have a lot of work to do to remove all the redundant information. Ideally, debug info is generated only once for each type across all compilation units. The default, -g, only generates debug info for types of variables that are actually used by a module. This greatly cuts down on the size of the object file. In addition, since C++ class hierarchies tend to be very complex, -g generates class debugging information only for classes for which a corresponding virtual function table is generated. -g is the right choice for programs that do not reference libraries or DLL's for which type info is needed. Sometimes, though, if part of a class implementation lies inside a DLL, the debug info for that class may never get generated. Thus, the -gf flag exists to cause full debug info to be generated for each class that is reference by generated code. Even -gf can get a bit problematic, since it can cause large quantities of debug info to be generated. It also never generates debug info for classes that only may be referenced in a linked-in library or DLL which were compiled separately without debug info. -gh causes debug info to be generated for all global structs and typedefs, regardless of if they are referenced or not. One could just use -gh for all compilations, and it will work, but it will be a bit slow. A better solution is to use -g for all the modules in the program. Then, create a special file TOTAL.C, which has a #include statement in it for each header that references a library or DLL. Compile TOTAL.C with -gh (and the other memory model, etc. switches), and TOTAL.OBJ will contain all the debug info you need for those DLLs and libraries. This will minimize compile/link times, which is important for fast development turnaround. OBJ2ASM can be run on any .OBJ file, and it will format and pretty-print any debug info found in the file. This is handy if you're curious as to what the compiler is doing. -g Generate line info and debug info for types of referenced variables. Equivalent to -gsl. Type info for typedefs and enums is not generated.
-g- turn off debug output -g3 Generate Codeview 3 format debug info. This is useful to support old debuggers, but is now obsolete. It is no longer supported. -g4 Generate Codeview 4 format debug info. This is the default. -g5 Generate Digital Mars format. -gd Dynamic C++ type info (obsolete) -gf Generate debug info for full class hierarchy for any referenced classes. -gg Make static functions global. This is useful when tools that read .MAP files are needed, since only global function names will appear in the .MAP file. If a C++ inline function is outlined, it still remains static, even with the -gg option enabled. This is because name collisions in this case are difficult to prevent. A C++ inline function is outlined if:
There is no space between -l and listfile. -L Using non-Digital Mars linker Digital Mars linkers have some extra features in them (like support for long command lines), -L means a non-Digital Mars linker will be run so those features cannot be used. -Llinker Use linker linker instead of default. This is useful if a special linker is being used, or if the linker is not on the PATH or in the directory where SC resides. For example, -L\path\mylink tells the compiler to run the MYLINK linker in the \path directory. -L/switch Pass /switch to linker. For example, this command: sc test -L/packcode -L\test\prog adds the option /packcode and the library search path \test\prog to the linker's command line. -Masm specify assembler to use MASM is normally the assembler called by SC when an assembler source file needs to be assembled. Use -M to specify an alternate assembler asm. For example, -M\path\masm tells the compiler to run the MASM in the \path directory. -M/switch Pass /switch to assembler -m[tsmclvfnrpxz][do][w][u] Select memory model 16 Bit Models t Tiny: small model program linked specially to create .COM file s Small: small code and data (default) m Medium: large code, small data c Compact:small code, large data l Large: large code and data v VCM (Virtual Code Manager) (obsolete) r Rational Systems 16 bit DOS Extender z Zortech ZPM 16 bit DOS Extender (obsolete) 32 Bit Models f OS/2 2.0 32 bit flat model (not supported) n Win32 32 bit flat model (default) p Pharlap 32 bit DOS Extender (obsolete) x DOSX 32 bit DOS Extender (obsolete) Memory Model Modifiers d DOS 16 bit (default) o OS2 16 bit (obsolete) Indicates code will be targeted towards an OS/2 16 bit executable. w assume SS != DS Use the w flag in combination with the -m option to make sure that the stack segment (SS) is not equal to the data segment (DS). Certain types of executables require that the DS and the SS be different. These are: ° 16-bit dynamic link libraries (DLLs) ° 16-bit multithreaded code u reload DS Use the u flag in combination with the -m option to instruct the compiler to always reload DS from the current value of DGROUP upon function entry. Note that u does not also imply that the DS and the SS are different (use w for that, as described above). If you are compiling 16 bit Windows code, use the -W switches instead of the w or u modifiers to the -m flag. This will prevent order dependencies, since a -W switch appearing after a -m switch will override the w or u modifiers on the -m switch, and vice versa. -Nc function level linking This causes each global or static function to be placed into its own COMDAT record. This will enable function level linking. Function level linking means that only functions actually referenced by other code will be pulled in and placed in the final executable. -NC don't generate COMDATs (obsolete) Avoid using this switch. It is now obsolete, since current linkers now all support COMDAT records. -ND compile and link with DLL version of runtime library Defines and sets _MT and _DLL to one. Changes the embedded RTL name from SNN.LIB to SND.LIB. This must be used only with the Win32 memory model (-mn). -NF ignore extended keywords The keywords __far, __huge, __loadds, __interrupt, __handle are ignored. (This is the default for N and F memory models.) -NF can be useful for compiling old 16 bit code for the x or p memory models. -NL Do not embed default library record The compiler normally embeds in the object file a record indicating the default runtime library to be linked in. -NL suppresses this embedding. This is useful when: o Compiling code that will go into a library, getting rid of all those records can result in a substantial reduction in library size. o Compiling code that will be linked with code generated by other compilers. -NLlibfile Embed the filename libfile.lib into the object file instead of the default. -Ns place expression strings in code seg Places strings that appear in expressions into the code segment rather than the data segment. Expression strings are always placed anyway in the code segment if the type of the expression is __cs*. The -Ns switch will place expression strings into the code segment that are typed as far pointers (the default in large data models). -Ns is ignored for FLAT memory models (-mn, -mf). -Ns is useful for 16 bit Windows programs to reduce DGROUP usage. Note that you cannot write into strings placed in the code segment. If you need to write into a string, and wish to use -Ns, make the particular writable string a static array. -Ns does not place strings in statically initialized data structures into the code segment. -NS new code seg for each function Causes a new code segment to be started each time a global far function is encountered. The name of the segment is the name of the function, with _TEXT appended. Because near functions cannot cross segment boundaries, all near functions must immediately follow any global functions that call them and cannot be called by more than one global function. -Nt use old template name mangling scheme (obsolete) By default, the compiler generates VC compatible name mangling. For compatibility with object code with pre-version 7.2 compilers, the -Nt switch enables the old template mangling scheme. -NTname Set code segment name to name. Sets code segment name, rather than using the default, module_TEXT. -NV Put virtual function tables in far data segments. Put virtual function tables in far data segments. by default. The default behavior is to put vtbls in the code segment for the Compact and Large memory models and for all 32-bit data models. For programs compiled with the Tiny, Small, or Medium models, the compiler places vtbls in DGROUP. This option is useful for saving code space in Compact and Large model programs. Borland C++ puts vtbls in the data segment by default; Microsoft C++ treats them as does Digital Mars C++. -o[-+flag] run optimizer with flag -o- No optimization (default) -o Optimize for program speed -o+space Optimize for program size -o SPP only: send result to stdout -ofilename Specify output filename This specifies the name of the object [.obj] file if the -c switch is used, otherwise it specifies the output executable [.exe] file name. The dot extension is optional. -p turn off autoprototyping -p- turn on autoprototyping (default) Autoprototyping is a Digital Mars C feature where if a function call is made and there is no prototype for the function, the compiler will create a prototype for that function based on the number and types of the arguments to it. Subsequent calls to that function will be checked against that prototype. This obviously can cause trouble if functions that accept a variable number of arguments (like printf()) are called without a prototype for that function in scope. Autoprototyping is irrelevant in C++ or if -r is used, because prototypes are then required. -P Default to pascal linkage Makes Pascal the default linkage for all functions and global data, instead of cdecl. Since all C library routines have cdecl linkage, they must be prototyped as such before being called. The main function must also be declared to have cdecl linkage or the linker cannot find it. For more information on declaring code to have alternative linkage, see Chapter 4, "Mixing Languages." Using Pascal as the default linkage type results in about a 3% code size reduction and corresponding speed increase in generated code. -P- Default to cdecl linkage -Pz Default to stdcall linkage -r strict prototyping -r- turn off -r (default) Enforces strict prototyping (all functions must be declared and prototyped before use). Standard library functions must include the appropriate header files. This behavior is the default for the C++ compiler and is highly recommended for C code, since it helps eliminate errors caused by type mismatches. -R put switch tables in code segment Switch tables are normally placed in the data segment (DGROUP). Sometimes, DGROUP space can be very limited, so the -R switch can be used to place switch tables into the code segment. Generated code will be slightly bigger and slower for switch statements with -R. -R is ignored for 32 bit programs. -s stack overflow checking Inserts code into the function prologs to check for stack overflows. The resulting program generates an error message and aborts if it detects a stack overflow at run-time. This option is particularly useful for code with heavily recursive functions. This switch is of interest mainly for 16 bit programs. Note: The compiler does not support stack overflow checking for programs compiled with the DOSX (-mx) memory model. -S always generate stack frame Generates a stack frame for each function. You typically use -S when working with a symbolic debugger, but you can also specify it by itself. The compiler always generates stack frames if you specify either the -g or -gs option. Without -S, the compiler does not generate a stack frame for functions with no local variables and no arguments. -u suppress predefined macros -v[0|1|2] verbose compile -v0 Do not display any messages. -v1 Default -v -v2 Displays source and header file names, classes, and functions while they are being compiled. Displays total compilation time. -w[-|n|x] warning messages -w suppress all warning messages -wn suppress warning message n See "Warnings and associated warning numbers" for messages. -w- enable all warning messages (default) -wx treat warnings as errors Warning messages tend to quickly scroll off the screen and go unnoticed, especially during building projects with lots of source files. -wx will treat warnings as errors, so they cannot be accidentally overlooked. -W{0123ADadefmrstuvwx-+} Windows prolog/epilog 1: Full 2: Reduced 3: Smart callback A: EXE D: DLL See Windows Prolog/Epilog Code Generation. -x turn off compilation error maximum Since many reported errors in a source file tend to be cascaded from the first error, the compiler normally aborts compiling a file after a certain number of errors are reported. Using -x will cause the compiler to proceed and try to compile the rest of the file. -XD instantiate template for any functions declared but not defined -XD- turn off -XD (default) Consider the following: template<T> int func(T) { return T; } int func(double); By default, since the specific declaration of func(double) exists, the compiler will not generate an instance of the template func(double), even if func(double) is called later in the source file. The programmer must provide an explicit definition of func(double) with a body at some point in the source code to the program. If -XD is specified, the two lines above tell the compiler to generate an instance of func(double) from the template of func(T) as long as no explicit function body for func(double) appears in that same source file. With -XD, the generated instance is placed into a COMDAT record, which means that if an explicit body is provided in another source file, that explicit definition will override the generated COMDAT definition. If the source file with the explicit body is compiled with -Nc (generate COMDATs for functions), then a linker error will result because there will be two different definitions for func(double). -XD is the way the Digital Mars compiler versions previous to 7.0 worked by default, and is so provided for compatibility with previous versions. -XIspec Create instance of template Generate specific instances of templates that appear in the source file being compiled. For example, suppose the file test1.cpp contains the function template: template< class T> T min(T a, T b) { return a < b ? a : b; } To create two instances of min() from test1.cpp (one for integers and one for doubles), use this command line: sc -c -XImin(int, int) -XImin(double, double) test1 Similarly, suppose stack.h contains this class template: template< class T> class stack { private: T* top; T* bottom; int size; public: stack(int s) { top = bottom = new T[size = s]; } ~stack() { delete[size] bottom; } void push(T a) { *top++ = a; } T pop() { return *--top; } int size() const; } and test2.cpp contains this template: #include <stack.h> template<class T> int stack<T>::size() const { return top - bottom; } To create a class for a stack of float types, use this command line: sc -c "-XIstack<float>" test2 Enclose this instance of the -XI option in quotation marks, since it contains the characters < and >. Without the quotation marks, the operating system would interpret the less-than (<) and greater-than (>) signs as file-redirection commands. -XN no template function instantiation Do not automatically expand any template function bodies. =nnnn set stack size for compiler passes (obsolete) -[0|2|3|4|5|6] 88/286/386/486/P5/Pro code Select CPU instruction type. -0 Generate code for 8088 and later CPUs -2 Generate code for 286 and later CPUs -3 Generate code for 386, 486, Pentium and Pentium Pro, and select instruction sequences that favor the 386 -4 Generate code for 386, 486, Pentium and Pentium Pro, and select instruction sequences that favor the 486 -5 Generate code for 386, 486, Pentium and Pentium Pro, and select instruction sequences that favor the Pentium -6 Generate code for 386, 486, Pentium and Pentium Pro, and select instruction sequences that favor the Pentium Pro This chart shows which CPUs each switch is compatible with: -0 -2 -3 -4 -5 -6 +----------------- 8088 | Y 286 | Y Y 386 | Y Y Y Y Y Y 486 | Y Y Y Y Y Y Pentium | Y Y Y Y Y Y Pro | Y Y Y Y Y Y Selecting a CPU type does not affect the memory model chosen, but -0 and -2 are invalid for 32 bit memory models. Since running Windows programs on an 8088 or a 286 is completely impractical, use -3, -4 or -5 even when generating 16 bit Windows code. -6 is the default for 32 bit memory models. The compiler supports the MMX instruction set in the inline assembler. MMX support is not affected by the CPU instruction type selection. When using -3 or higher for 16 bit programs, beware of crash bugs resulting from conflicts with DOS terminate-and-stay-resident programs (TSRs) that do not save or restore the high-order 16 bits of the 32-bit registers.