cpp.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Sat, 10 Feb 2018 01:36:16 +0200
changeset 2229 1a0b6597e594
parent 2228 837f1337c59b
permissions -rw-r--r--
Mark block quot in HTMLe.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1086
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     1
.. -*- coding: utf-8; -*-
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     2
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     3
=======================
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     4
 cpp (C preprocessor).
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     5
=======================
1344
4a4dabb9f8e4 Fix to satisfy structure convention.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1334
diff changeset
     6
.. contents::
1905
fba288d59662 Include only local subsections into TOC. This prevent duplication of
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1347
diff changeset
     7
   :local:
1086
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     8
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     9
How to see macros expansion?
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    10
============================
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    11
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    12
GCC::
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    13
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    14
  $ cpp <file>.c
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    15
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    16
MSVC::
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    17
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    18
  $ cl /E <file>.c
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    19
1347
0147cb61177f Fix typo. Add about Emacs and cpp.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1344
diff changeset
    20
Under Emacs select region and type ``C-c C-e``.
0147cb61177f Fix typo. Add about Emacs and cpp.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1344
diff changeset
    21
0147cb61177f Fix typo. Add about Emacs and cpp.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1344
diff changeset
    22
How to see predefined macros?
1086
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    23
=============================
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    24
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    25
See:
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    26
2228
837f1337c59b Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
    27
http://predef.sourceforge.net/
837f1337c59b Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
    28
  ``predef`` project on Sourceforge
837f1337c59b Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
    29
http://en.wikipedia.org/wiki/C_preprocessor#Compiler-specific_predefined_macros
837f1337c59b Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
    30
  Compiler specific predefined macros
837f1337c59b Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
    31
http://msdn.microsoft.com/en-us/library/b0084kay.aspx
837f1337c59b Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
    32
  Predefined Macros
1086
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    33
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    34
GNU C Compiler::
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    35
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    36
  $ gcc -dM -E - < /dev/null
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    37
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    38
HP-UX ansi C compiler::
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    39
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    40
  $ cc -v EMPTY.c
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    41
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    42
SCO OpenServer C compiler::
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    43
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    44
  $ cc -## EMPTY.c
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    45
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    46
Sun Studio C/C++ compiler::
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    47
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    48
  $ cc -## EMPTY.c
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    49
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    50
IBM AIX XL C/C++ compiler::
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    51
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    52
  $ cc -qshowmacros -E EMPTY.c
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    53
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    54
For Visual Studio compiler there no any possibility get predefined macros from
1087
e1b19e1e7031 Add info about _MSC_VER
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1086
diff changeset
    55
command line... But some macros documented:
1086
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    56
2228
837f1337c59b Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
    57
``_MSC_VER``
837f1337c59b Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
    58
  Defines the compiler version. Always defined.
837f1337c59b Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
    59
``_WIN32``
837f1337c59b Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
    60
  Defined for applications for Win32. Always defined.
1086
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    61
1087
e1b19e1e7031 Add info about _MSC_VER
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1086
diff changeset
    62