Go to the first, previous, next, last section, table of contents.


3. Invoking

The command names given below are the standard names. However the compiler may have been installed with a prefix, in which case the prefix should be added at the start of the name. Often the prefix will be `cob'.

Normally the preprocessor and main compiler would be invoked via `gcc' but this is not recommended as the requires `specs' file is not quite complete. You can try it out - the parameters are available from `gcc -help'.

3.1 COBOL Editing mode for emacs - cobol.el


emacs is the worlds best/worst text editor. Many people use it. cobol.el
provides support in emacs for color syntax highlighting, auto indenting,
etc, just like the editing modes for other languages.

First byte compile into cobol.elc according to the usual emacs
procedure (M-x byte-compile-file).

You can add this to your .emacs, to make it start automagically in
cobol mode when you open a cobol file.  I've done it the way I did it
because it's case-sensitive.  I leave it to your own considerable
imagination to decide where in .emacs to put these, or what to modify.:

(autoload 'cobol-mode "cobol" "COBOL Editing mode" t)
(if first-time
    (setq auto-mode-alist
          (append '(("\\.cpp$" . c++-mode)
                    ("\\.hpp$" . c++-mode)
                    ("\\.lsp$" . lisp-mode)
                    ("\\.scm$" . scheme-mode)
                    ("\\.pl$"  . perl-mode)
                    ("\\.cbl$" . cobol-mode)
                    ("\\.CBL$" . cobol-mode)
                    ("\\.COB$" . cobol-mode)
                    ("\\.cob$" . cobol-mode)
                     ("\\.CPY$" . cobol-mode)
                    ("\\.cpy$" . cobol-mode)
                   ) auto-mode-alist)))

;; Auto font lock mode
(defvar font-lock-auto-mode-list
  (list 'c-mode 'c++-mode 'c++-c-mode 'emacs-lisp-mode 'lisp-mode
'perl-mode 'scheme-mode 'scribe-mode 'shell-script-mode 'cobol-mode
'dired-mode)
  "List of modes to always start in font-lock-mode")

(defvar font-lock-mode-keyword-alist
  '((c++-c-mode . c-font-lock-keywords)
    (perl-mode . perl-font-lock-keywords)
    (cobol-mode . cobol-font-lock-keywords)
    (dired-mode . dired-font-lock-keywords))
  "Associations between modes and keywords")

(add-hook 'cobol-mode-hook
          '(lambda ()
             (set (make-local-variable 'dabbrev-case-fold-search) t)
             (set (make-local-variable 'dabbrev-case-replace) t)))

3.2 ASCII to EBCDIC Conversion coba2e

Usage (convert ASCII file to EBCDIC):
coba2e -v --version
 -h --help -i inputfile --input-file inputfile
 -o outputfile --output-file outputfile
 inputfile and outputfile default to  stdin/stdout

3.3 EBCDIC to ASCII Conversion cobe2a

Usage (convert EBCDIC file to ASCII):
cobe2a -v --version
 -h --help -i inputfile --input-file inputfile
 -o outputfile --output-file outputfile
 inputfile and outputfile default to  stdin/stdout

3.4 DOS text to Unix text Conversion cobd2u

Usage (convert DOS text file to Unix):
cobd2u -v --version
 -h --help -i inputfile --input-file inputfile
 -o outputfile --output-file outputfile
 inputfile and outputfile default to  stdin/stdout

3.5 Unix text to DOS text Conversion cobu2d

Usage (convert Unix text file to DOS):
cobu2d -v --version
 -h --help -i inputfile --input-file inputfile
 -o outputfile --output-file outputfile
 inputfile and outputfile default to  stdin/stdout

3.6 Fixed Length to Variable Length Records cobf2v

Usage (convert fixed text file to variable Length):
cobf2v -v --version
 -h --help 
-i inputfile --input-file inputfile
 -e --escape-special (output control chars in strings as " & x"hh" & ")
 -l 99...9 --line-length 99...9 (line length)
 -t 99...9 --truncation-length 99...9 (truncate lines to this value)
 -o outputfile --output-file outputfile
 inputfile and outputfile default to stdin/stdout

Note there is no variable to fixed conversion utility.

3.7 COBOL Preprocessor cobpre

Normally this would be invoked via the main compiler `gcc'.

Usage (COBOL preprocessor cobpre V1.2.5):
cobpre 
 --help 
 -v (display version number)
 -i inputfile (req'd - when used within gcc, 
    the input files should be just included at the end of  the option list eg 'gcc infile.cob')
 -o outputfile

 -C (do not output comments)
 -P (do not output # "line number" lines in output file for debugging)
 -$ (do not permit $ in variable names)
 -ffixeol (add spaces to end lines when needed for syntax - default)
 -fnofixeol (don't add spaces to end lines when needed for syntax)
 -fnoseq  (input files have no sequence numbers - default)
 -fseq  (input files have sequence numbers)
 -fmax-nesting-level 99...9 max copy depth default 10
 -fR-margin=MARGIN (eg -fR-margin=72 default is R-margin at the end of each line, most compilers set it to after column 72)
 -ddump-line (debug - dump lines after initial preprocessing)
 -ddump-token (debug - dump tokens after lexical analysis)
 -ddump-copyrepl (debug - dump copy/replace verb information)
 -ddump-file (debug - dump file as it is read in)
 -dstop-before-parse (debug - stop before doing parse)
 -dparser-trace (debug - trace parser actions)
 -ddump-R-margin (debug - dump file after R-margin is processed)

 -ansi (warn about non-ansi 85 compliance).
 -pedantic (warn about non-ansi 85 compliance).
 -pedantic-errors (errors for non-ansi 85 compliance).
 -H (print copy file names as they are opened).
 -I directory (specify *the* default copy file directory
    - overrides SYSLIB in an environment variable
 -I name=directory (copy library directory name)
    - overrides NAME in an environment variable

 By default fatal, error, warning and unsupported are printed and counted

 -w inhibit printing and counting warning and obsolete messages)
 -Wall (warn about everything except NonStandard)
 -WnoXXX    where XXX is Warning FYI Efficiency Obsolete Unsupported NonStandard
            do not print or count messages of that type
 -WXXX      (XXX as above) print and count messages of that type
 -WXXX-error treat XXX (as above) as an error
 -WXXX-no-error do not treat XXX (as above) as an error; other than fatal and error, only Unsupported is by default treated as an errorUsage (expand tabs in file):
cobutab -v --version
 -h --help 
 -i inputfile --input-file inputfile
 -o outputfile --output-file outputfile
 -r 99...9 --tab-regular 99...9 (tab every 99...9 columns)
 -c 99...9 --tab-column 99...9 (tab at this column
          may specify multiple columns)
 inputfile and outputfile default to stdin/stdout

3.8 Main COBOL Compiler cobcc1

Normally this would be invoked via the main compiler `gcc'.

Usage: cobcc1 input [switches]
Switches:
  -ffixed-<register>      Mark <register> as being unavailable to the compiler
  -fcall-used-<register>  Mark <register> as being corrupted by function calls
  -fcall-saved-<register> Mark <register> as being preserved across functions
  -finline-limit=<number> Limits the size of inlined functions to <number>
  -fbounds-check          Generate code to check bounds before dereferencing pointers and arrays
  -fbounded-pointers      Compile pointers as triples: value, base & end
  -fmath-errno            Set errno after built-in math functions
  -fpeephole2             Enables an rtl peephole pass run before sched2
  -fident                 Process #ident directives
  -fleading-underscore    External symbols have a leading underscore
  -fssa                   Enable SSA optimizations
  -finstrument-functions  Instrument function entry/exit with profiling calls
  -fdump-unnumbered       Suppress output of instruction numbers and line number notes in debugging dumps
  -fprefix-function-name  Add a prefix to all function names
  -fcheck-memory-usage    Generate code to check every memory access
  -falign-functions       Align the start of functions
  -falign-labels          Align all labels
  -falign-jumps           Align labels which are only reached by jumping
  -falign-loops           Align the start of loops
  -fstrict-aliasing       Assume strict aliasing rules apply
  -fargument-noalias-global Assume arguments do not alias each other or globals
  -fargument-noalias      Assume arguments may alias globals but not each other
  -fargument-alias        Specify that arguments may alias each other & globals
  -fstack-check           Insert stack checking code into the program
  -fpack-struct           Pack structure members together without holes
  -foptimize-register-move Do the full regmove optimization pass
  -fregmove               Enables a register move optimisation
  -fgnu-linker            Output GNU ld formatted global initialisers
  -fverbose-asm           Add extra commentry to assembler output
  -fdata-sections         place data items into their own section
  -ffunction-sections     place each function into its own section
  -finhibit-size-directive Do not generate .size directives
  -fcommon                Do not put unitialised globals in the common section
  -ffast-math             Improve FP speed by violating ANSI & IEEE rules
  -frename-registers      Do the register renaming optimization pass
  -freorder-blocks        Reorder basic blocks to improve code placement
  -fbranch-probabilities  Use profiling information for branch probabilities
  -ftest-coverage         Create data files needed by gcov
  -fprofile-arcs          Insert arc based program profiling code
  -fasynchronous-exceptions Support asynchronous exceptions
  -fsjlj-exceptions       Use setjmp/longjmp to handle exceptions
  -funwind-tables         Just generate unwind tables for exception handling
  -fnew-exceptions        Use the new model for exception handling
  -fexceptions            Enable exception handling
  -fpic                   Generate position independent code, if possible
  -fbranch-count-reg      Replace add,compare,branch with branch on count reg
  -fsched-spec-load-dangerous Allow speculative motion of more loads
  -fsched-spec-load       Allow speculative motion of some loads
  -fsched-spec            Allow speculative motion of non-loads
  -fsched-interblock      Enable scheduling across basic blocks
  -fschedule-insns2       Run two passes of the instruction scheduler
  -fschedule-insns        Reschedule instructions to avoid pipeline stalls
  -fpretend-float         Pretend that host and target use the same FP format
  -fdelete-null-pointer-checks Delete useless null pointer checks
  -frerun-loop-opt        Run the loop optimiser twice
  -frerun-cse-after-loop  Run CSE pass after loop optimisations
  -fgcse                  Perform the global common subexpression elimination
  -fdelayed-branch        Attempt to fill delay slots of branch instructions
  -freg-struct-return     Return 'short' aggregates in registers
  -fpcc-struct-return     Return 'short' aggregates in memory, not registers
  -fcaller-saves          Enable saving registers around function calls
  -fshared-data           Mark data as shared rather than private
  -fsyntax-only           Check for syntax errors, then stop
  -fkeep-static-consts    Emit static const variables even if they are not used
  -finline                Pay attention to the 'inline' keyword
  -fkeep-inline-functions Generate code for funcs even if they are fully inlined
  -finline-functions      Integrate simple functions into their callers
  -ffunction-cse          Allow function addresses to be held in registers
  -fforce-addr            Copy memory address constants into regs before using
  -fforce-mem             Copy memory operands into registers before using
  -fpeephole              Enable machine specific peephole optimisations
  -fwritable-strings      Store strings in writable data section
  -freduce-all-givs       Strength reduce all loop general induction variables
  -fmove-all-movables     Force all loop invariant computations out of loops
  -funroll-all-loops      Perform loop unrolling for all loops
  -funroll-loops          Perform loop unrolling when iteration count is known
  -fstrength-reduce       Perform strength reduction optimisations
  -fthread-jumps          Perform jump threading optimisations
  -fexpensive-optimizations Perform a number of minor, expensive optimisations
  -fcse-skip-blocks       When running CSE, follow conditional jumps
  -fcse-follow-jumps      When running CSE, follow jumps to their targets
  -foptimize-sibling-calls Optimize sibling and tail recursive calls
  -fomit-frame-pointer    When possible do not generate stack frames
  -fdefer-pop             Defer popping functions args from stack until later
  -fvolatile-static       Consider all mem refs to static data to be volatile
  -fvolatile-global       Consider all mem refs to global data to be volatile
  -fvolatile              Consider all mem refs through pointers as volatile
  -ffloat-store           Do not store floats in registers
  -O[number]              Set optimisation level to [number]
  -Os                     Optimise for space rather than speed
  -pedantic               Issue warnings needed by strict compliance to ANSI C
  -pedantic-errors        Like -pedantic except that errors are produced
  -w                      Suppress warnings
  -W                      Enable extra warnings
  -Wpadded                Warn when padding is required to align struct members
  -Wpacked                Warn when the packed attribute has no effect on struct layout
  -Winline                Warn when an inlined function cannot be inlined
  -Wuninitialized         Warn about unitialized automatic variables
  -Wunreachable-code      Warn about code that will never be executed
  -Wcast-align            Warn about pointer casts which increase alignment
  -Waggregate-return      Warn about returning structures, unions or arrays
  -Wswitch                Warn about enumerated switches missing a specific case
  -Wshadow                Warn when one local variable shadows another
  -Wunused                Warn when a variable is unused
  -Wid-clash-<num>        Warn if 2 identifiers have the same first <num> chars
  -Wlarger-than-<number>  Warn if an object is larger than <number> bytes
  -p                      Enable function profiling
  -a                      Enable block profiling 
  -ax                     Enable jump profiling 
  -o <file>               Place output into <file> 
  -G <number>             Put global and static data smaller than <number>
                           bytes into a special section (on some targets)
  -gdwarf-2               Enable DWARF-2 debug output
  -gdwarf+                Generated extended DWARF-1 format debug output
  -gdwarf                 Generate DWARF-1 format debug output
  -gstabs+                Generate extended STABS format debug output
  -gstabs                 Generate STABS format debug output
  -ggdb                   Generate default extended debug format output
  -g                      Generate default debug format output
  -aux-info <file>        Emit declaration info into <file>.X
  -quiet                  Do not display functions compiled or elapsed time
  -version                Display the compiler's version
  -d[letters]             Enable dumps from specific passes of the compiler
  -dumpbase <file>        Base name to be used for dumps from specific passes
  -fsched-verbose=<number> Set the verbosity level of the scheduler
  --help                  Display this information

Language specific options:
 Options for COBOL:
  -fmain                  program is the main entry point
  -fdump-syntax-tree      debug dump syntax tree
  -fno-default-inline     Do not inline member functions by default
  -fdump-translation-unit Dump the entire translation unit to a file
  -fno-rtti               Do not generate run time type descriptor information
  -fno-gnu-keywords       Do not recognise GNU defined keywords
  -fno-implement-inlines  Export functions even if they can be inlined
  -fpermissive            Downgrade conformance errors to warnings
  -fstats                 Display statistics accumulated during compilation
  -fno-strict-prototype   Do not assume that empty prototype means no args
  -fxref                  Emit cross referencing information
  -Wreturn-type           Warn about inconsistent return types
  -Weffc++                Warn about violations of Effective C++ style rules
  -Wno-deprecated         Don't announce deprecation of compiler features

Target specific options:
  -mno-accumulate-outgoin Do not use push instructions to save outgoing arguments
  -maccumulate-outgoing-a Use push instructions to save outgoing arguments
  -mno-push-args          Do not use push instructions to save outgoing arguments
  -mpush-args             Use push instructions to save outgoing arguments
  -mno-inline-all-stringo Do not inline all known string operations
  -minline-all-stringops  Inline all known string operations
  -mno-align-stringops    Do not align destination of the string operations
  -malign-stringops       Align destination of the string operations
  -mintel-syntax          Emit Intel syntax assembler opcodes
  -mstack-arg-probe       Enable stack probing
  -momit-leaf-frame-point Omit the frame pointer in leaf functions
  -mfancy-math-387        Generate sin, cos, sqrt for FPU
  -mno-fancy-math-387     Do not generate sin, cos, sqrt for FPU
  -mno-fp-ret-in-387      Do not return values of functions in FPU registers
  -mfp-ret-in-387         Return values of functions in FPU registers
  -mno-ieee-fp            Do not use IEEE math for fp comparisons
  -mieee-fp               Use IEEE math for fp comparisons
  -mno-svr3-shlib         Uninitialized locals in .data
  -msvr3-shlib            Uninitialized locals in .bss
  -mno-align-double       Align doubles on word boundary
  -malign-double          Align some doubles on dword boundary
  -mno-rtd                Use normal calling convention
  -mrtd                   Alternate calling convention
  -mpentiumpro            Same as -mcpu=pentiumpro
  -mpentium               Same as -mcpu=pentium
  -m486                   Same as -mcpu=i486
  -m386                   Same as -mcpu=i386
  -mno-soft-float         Use hardware fp
  -msoft-float            Do not use hardware fp
  -mhard-float            Use hardware fp
  -mno-80387              Do not use hardware fp
  -m80387                 Use hardware fp
  -mbranch-cost=          Branches are this expensive (1-5, arbitrary units)
  -mpreferred-stack-bound Attempt to keep stack aligned to this power of 2
  -malign-functions=      Function starts are aligned to this power of 2
  -malign-jumps=          Jump targets are aligned to this power of 2
  -malign-loops=          Loop code aligned to this power of 2
  -mregparm=              Number of registers used to pass integer arguments
  -mreg-alloc=            Control allocation order of integer registers
  -march=                 Generate code for given CPU
  -mcpu=                  Schedule code for given CPU

There are undocumented target specific options as well.


Go to the first, previous, next, last section, table of contents.