SDCPP traditional C preprocessing

From SDCC wiki
Revision as of 10:48, 4 December 2012 by Borutr (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

C preprocessing - SDCPP

Invoked from sdcc. Takes input file, processes it and the output is internally fed to the parser "character by character" (token by token).

Although in this way the input is processed "in parallel" with the rest of the compiler, theoretically it would be possible that the preprocessor would be invoked standalone, output into a temporary file which would in turn fed into the lexer of the compiler, as the preprocessors does not share any data with the rest of the compiler.

sources

sdcc/src/support/cpp2/*

what does it do

  • expands macros/defined constants
  • processes the preprocessor pragma directives and transfers all other pragmas to the parser. Preprocessor pragmas are:
    • Global:
      • #pragma once
    • GCC sspecific:
      • #pragma GCC poison
      • #pragma GCC system_header
      • #pragma GCC dependency
    • SDCC specific:
      • #pragma sdcc_hash
      • #pragma preproc_asm
      • #pragma pedantic_parse_number
  • include files?
  • conditional compilation?
  • remove comments?
  • anything else???
  • internal flow: ??? see sdcc/src/support/cpp2/

input

  • C source file (for the particular target)

output

  • preprocessed C source, but normally SDCPP is invoked from SDCC and the result is fed directly to the compiler (via a pipe) without being stored anywhere

remarks

  • SDCPP has a lot of options - run sdcpp --help
  • SDCC calls SDCPP and passes some of the options from its command line and adds other options (???)
  • SDCPP is an adopted GCC preprocessor - see SDCPP history
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox