cpp.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Mon, 22 Feb 2016 12:46:36 +0200
changeset 1905 fba288d59662
parent 1347 0147cb61177f
child 1912 8b81a8f0f692
permissions -rw-r--r--
Include only local subsections into TOC. This prevent duplication of TOC when build single page HTML document. Also this make unnecessary CSS hack to hide document title as top level section.

.. -*- coding: utf-8; -*-
.. include:: HEADER.rst

=======================
 cpp (C preprocessor).
=======================
.. contents::
   :local:

How to see macros expansion?
============================

GCC::

  $ cpp <file>.c

MSVC::

  $ cl /E <file>.c

Under Emacs select region and type ``C-c C-e``.

How to see predefined macros?
=============================

See:

  http://predef.sourceforge.net/
                ``predef`` project on Sourceforge
  http://en.wikipedia.org/wiki/C_preprocessor#Compiler-specific_predefined_macros
                Compiler specific predefined macros
  http://msdn.microsoft.com/en-us/library/b0084kay.aspx
                Predefined Macros

GNU C Compiler::

  $ gcc -dM -E - < /dev/null

HP-UX ansi C compiler::

  $ cc -v EMPTY.c

SCO OpenServer C compiler::

  $ cc -## EMPTY.c

Sun Studio C/C++ compiler::

  $ cc -## EMPTY.c

IBM AIX XL C/C++ compiler::

  $ cc -qshowmacros -E EMPTY.c

For Visual Studio compiler there no any possibility get predefined macros from
command line... But some macros documented:

  _MSC_VER
                Defines the compiler version. Always defined.
  _WIN32
                Defined for applications for Win32. Always defined.