cpp.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Mon, 09 Oct 2017 10:49:36 +0300
changeset 2188 e95731eef030
parent 1912 8b81a8f0f692
child 2228 837f1337c59b
permissions -rw-r--r--
Fixed: NameError: name 'locale_encoding' is not defined File /bin/rst2html.py, line 17, in <module> from docutils.core import publish_cmdline, default_description File /usr/lib/python2.7/site-packages/docutils/core.py, line 20, in <module> from docutils import frontend, io, utils, readers, writers File /usr/lib/python2.7/site-packages/docutils/frontend.py, line 41, in <module> import docutils.utils File /usr/lib/python2.7/site-packages/docutils/utils/__init__.py, line 20, in <module> import docutils.io File /usr/lib/python2.7/site-packages/docutils/io.py, line 18, in <module> from docutils.utils.error_reporting import locale_encoding, ErrorString, ErrorOutput File /usr/lib/python2.7/site-packages/docutils/utils/error_reporting.py, line 60, in <module> codecs.lookup(locale_encoding or '') # None -> '' NameError: name 'locale_encoding' is not defined

.. -*- coding: utf-8; -*-

=======================
 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.