eĿlipsis
a language independent preprocessor
 
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Loading...
Searching...
No Matches
ellipsis-gnuc.sh File Reference

Preprocessing Frontend for C. More...

Namespaces

namespace  ellipsis-gnuc
 

Variables

Tools

Configurable command line tools

These can be used to adapt the script to your needs on systems that are not directly POSIX. The only one with importance here should be ELLIPSIS_CC which is used as the real C compiler after preprocessing.

 CAT = ${CAT:-cat}
 Command used to dump files to stdout.
 
 CP = ${CP:-cp}
 Command used to copy files.
 
 ECHO = ${ECHO:-echo}
 Echos its arguments to stdout.
 
 ELLIPSIS_CC = ${ELLIPSIS_CC:-cc}
 
 ELLIPSIS_VERBOSE = ${ELLIPSIS_VERBOSE:-0}
 Set to 1 to augment verbosity of the script.
 
 MKTEMP = ${MKTEMP:-mktemp}
 Used to create a temporay directory that is destroyed on exit.
 
 RM = ${RM:-rm}
 Delete files, should accept -rf to forcably delete directories recursively.
 
 SED = ${SED:-sed}
 The sed Stream EDitor as it comes with POSIX since the epoch.
 
 SORT = ${SORT:-sort}
 The sort utility as it comes with POSIX since the epoch, should understand the -u option.
 
 TMP = ${TMP:-/tmp}
 The top level directory used for temporary files.
 
Tuning

Variables that are used to tune eĿlipsis

You should generally not touch these.

 ELLIPSIS_MARK_LINE
 
 ELLIPSIS_MARK_LINE_RETURN
 
 ELLIPSIS_MARK_LINE_START
 
 ELLIPSIS_ONE_PHASE
 
 ELLIPSIS_PRAGMA_FORWARD
 

Detailed Description

Preprocessing Frontend for C.

In addition to the ellipsis preprocessor itself, this is used to determine predefined macros of a given compiler tool chain and to then preprocess source files with ellipsis using this knowledge. Thereby you should be able to use all extensions that eĿlipsis provides out of the box. I'd personally particularly recommend

This uses the following features to determine the basic preprocessor configuration of a C compiler, provided in the macro ELLIPSIS_CC. In general you should be able to use this as a first level replacement for your C compiler. For example if you have the make utility

ELLIPSIS_CC=gcc CC="ellipsis-gnuc.sh" make all

or

ELLIPSIS_CC=clang CC="ellipsis-gnuc.sh" make all

if you want to use clang instead of gcc. Obviously, for the above to work the compiler and ellipsis-gnuc.sh should be in your search path for executables. If not, you'd have to adapt that to provide the full path.

Properties that your C compiler should fulfill are as described for the POSIX c17 executable, namely arguments

  • -E for preprocessing only
  • -D for defining macros
  • -U for undefining macros
  • -I for include paths
  • -o for a (single) output path

and the suffixes

  • .c for C source files
  • .i for preprocessed C source files

In addition it builds on the commonly supported options for compilers that try to be compatible with GNUC,

  • -dM to dump macro definitions
  • -v to dump configuration information.

and also implements GNUC's option

  • -P to omit line number information in the output
  • -MM to dump make dependency information to stdout

Other options such as

  • -c to compile to one .o object file per translation unit
  • -S to compile to one .x assembly file per translation unit

are just forwarded to the native compiler underneath. In particular, if no such option is present this usually should link all translation units into one executable at the end. If no .c files are given this just passes all command line arguments through to the "real" compiler. In most case this will then link all object files together.

For -v, it is assumed that the default include path are listed between lines that read

#include <...> search starts here:
...
End of search list.

If no command line option is given, a file with predefined information similar to predefined-clang-14-x86_64-linux-gnu.h is produced. The name of that file is composed from guesses about the compiler, its primary version, the processor architecture, the OS and the C library.

Otherwise, the mechanism is as follows:

  • A header file ellipsis-predefined.h with that information is produced in a temporary directory and the name is exported as ELLIPSIS_PREDEFINED to the remaining steps.
  • Arguments that target the preprocessor are are collected to be passed on to ellipsis.
  • Source file names are collected and replaced in the argument list by file names with .i that are located in a temporary directory.
  • Ellipsis is called for each of the source files to produce the .i file(s).
  • Unless the -E option had been given, the compiler is called with the modified argument list.
  • If the -E option had been given, the result is either dumped to stdout, or into a file specified with the -o option.

Thereby the compiler should not see any arguments they don't know about, they operate in the same directory as before and they should not try to preprocess the .i files, again.

There are some special rules that apply:

  • Predefined macro names that are not standard conforming, such as e.g linux, are not transferred.
  • An isolated - option reads the source from stdin.
  • If - but not -E options haven been given, an output has to be specified with -o
  • If there are multiple source files with -E no output file may be specified.
  • This enables one-phase preprocessing of eĿlipsis, that is the token %% at the beginning of a line is the same as a #.

Some of preprocessor information was found at

https://sourceforge.net/p/predef/wiki/Home/