cpp.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Mon, 22 Feb 2016 12:41:52 +0200
changeset 1903 901e7394849f
parent 1347 0147cb61177f
child 1905 fba288d59662
permissions -rw-r--r--
Decrease intent to increase space usage on mobile.
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; -*-
1334
9bf0d5a1f0cf Include common header with quick links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1105
diff changeset
     2
.. include:: HEADER.rst
1086
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     3
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     4
=======================
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     5
 cpp (C preprocessor).
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     6
=======================
1344
4a4dabb9f8e4 Fix to satisfy structure convention.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1334
diff changeset
     7
.. contents::
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
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    27
  http://predef.sourceforge.net/
1105
f50956d9293a Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1087
diff changeset
    28
                ``predef`` project on Sourceforge
1086
66ecbe32a2af simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    29
  http://en.wikipedia.org/wiki/C_preprocessor#Compiler-specific_predefined_macros
1105
f50956d9293a Fix RST syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1087
diff changeset
    30
                Compiler specific predefined macros
1087
e1b19e1e7031 Add info about _MSC_VER
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1086
diff changeset
    31
  http://msdn.microsoft.com/en-us/library/b0084kay.aspx
e1b19e1e7031 Add info about _MSC_VER
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1086
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
1087
e1b19e1e7031 Add info about _MSC_VER
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1086
diff changeset
    57
  _MSC_VER
e1b19e1e7031 Add info about _MSC_VER
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1086
diff changeset
    58
                Defines the compiler version. Always defined.
e1b19e1e7031 Add info about _MSC_VER
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1086
diff changeset
    59
  _WIN32
e1b19e1e7031 Add info about _MSC_VER
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1086
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