关闭

Pre-defined C/C++ Compiler Macros

1193人阅读 评论(0) 收藏 举报
分类:


The macros are found here:

General guidelines are found here:

Please send updates/corrections to predef-contribute.

Introduction

C and C++ compilers automatically define certain macros that can be used to check for compiler or operating system features. This is useful when writing portable software.

These pages lists various pre-defined compiler macros that can be used to identify standards, compilers, operating systems, hardware architectures, and even basic run-time libraries at compile-time.

For example, if we want to use a generic or opaque pointer type, we use void pointers. However, ancient K&R compilers (from the time before the first ANSI C standard) do not support void pointers. Instead we can define our own type:

#if defined(__STDC__) || defined(__cplusplus) || defined(_MSC_EXTENSIONS)
typedef void * t_pointer;
#else
typedef char * t_pointer;
#endif

Another example, Microsoft Visual C++ version 4.2 added a pragma to reduce compilation times by only including a file once (if _MSC_VER is not defined then it will evaluate to 0 (zero) — however, some compilers may complain about an undefined macro)

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif

The macros contained in these pages have been obtained through vendor documentation, the defines script, contributors, and third-party source code. No guarantee about the correctness of the macros is given.

An often-used alternative is Autoconf, which is a more powerful tool to examine various types of features, including compilation options. However, Autoconf is fairly Unix-centric, and requires a Unix layer on other platforms (e.g. Cygwin on Windows). Other alternatives are BuildtoolCMakeSConsPMKJamAnt, andBakefile.

Contributors

Bjorn Reese, Daniel Stenberg, Greg Roelofs, Steven G. Johnson, Wlodzimierz ABX Skiba, Marc Finet, Philip Newton, Mitchell Charity, Christian Klutz, Seo Sanghyeon, Chris Adami, Geoff Clare, Dan Fandrich, Mike Gorchak, Yuri D'Elia, Gynvael Coldwind, Alain Tauch, Vadim Zeitlin, Steve White, Thomas David Rivers, Tom Honermann, Martin Mitas, Dinesh Chhadwa, Erik Faye-Lund, Leo Davis, Paul Hsieh, Roland Schwarz, Darko Kolakovic, Andy Buonviri, Ming Kin Lai, Kent Johnson, Helmut Bauer, Oliver Schneider, Ron Pimblett, Jose Luis Rodriguez Garcia, Jeroen Ruigrok van der Werven, Uffe Jakobsen, Bryan Ashby, Bruno Haible, Artur Bac, Terry Schwarz, Leo Davis, Markus Duft, William Dang, Paul Green, Ruben Van Boxem, Pau Garcia i Quiles, Mikulas Patocka, Leo Davis, Mark Ferry, Holger Machens, Simon Watts, Paul Hargrove, Hans-Christoph Steiner, Gerald Combs, Denys Bulant, Massimo Morara, Jeremy Bennett, Guillem Jover, Riku Voipio, Jacques Pelletier, Mark Jarvin, Georg Sauthoff, Scot Jenkins, Grzegorz Brzęczyszczykiewicz, John Dallman, Gianmichele Toglia.


Related

Wiki: VersionNormalization
Wiki: FeatureMacros
Wiki: Endianness
Wiki: Standards
Wiki: Compilers
Wiki: Libraries
Wiki: OperatingSystems
Wiki: Architectures

0
0
查看评论
发表评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场

Ubuntu 14.10,准备C/C++的编译环境

Ubuntu缺省情况下,并没有提供C/C++的编译环境,因此还需要手动安装。   如果单独安装gcc以及g++比较麻烦,幸运的是,为了能够编译Ubuntu的内核,Ubuntu提供了一个bui...
  • sunylat
  • sunylat
  • 2015-11-14 01:02
  • 2578

codeblocks编译出错问题的解答!(编译c++ 或者c程序)

典型错误: execution of 'mingw32-g++.exe ……faile! codeblocks cannot exec `cc1plus': No such file or direc...
  • jingmiaa
  • jingmiaa
  • 2016-07-28 12:58
  • 4443

Cygwin环境使用第三方ARMGCC编译eCos系统

第三方ARMGCC通常是基于Mingw32的,使用的是Windows路径,如C:\ecos\packages\infra\current\src\startup.cxx;而eCos配置工具生成的Mak...
  • zoomdy
  • zoomdy
  • 2014-09-25 16:28
  • 1537

C/C++ Standard Predefined Macros

C/C++常用预定义宏 __DATE__    进行预处理的日期(“mm dd yyyy”形式的字符串文字,如May 27 2006) __FILE__    代表当前源代码文件名的字符串文字 ,...
  • areskris
  • areskris
  • 2011-09-23 10:24
  • 627

Do-While and if-else statements in C/C++ macros

原贴: http://stackoverflow.com/questions/154136/do-while-and-if-else-statements-in-c-c-macros I...
  • KISSMonX
  • KISSMonX
  • 2012-09-28 22:17
  • 1082

OpenGL 环境搭建:win7 64位系统:eclipse + freeglut + GNU C/C++ Compiler MinGW

技巧一:怎样在windows上使用GNU的C编译器 技巧二:怎样使win7 x64 系统上的过时的OpenGL库函数和eclipse 和 GNU C Compiler发挥作用。   第一步,安装...
  • lc204
  • lc204
  • 2012-10-11 15:12
  • 2100

win10安装MDK5时,出现the arm C/C++ compiler已停止工作如何解决

出现问题的可能情况有三种。 一、电脑用户名使用了中文。 二、MDK的保存路径中有中文。 三、MDK5的保存路径和keil c51位于同一个文件夹下 四、MDK5的环境变量有中文情况
  • zhouchanghm
  • zhouchanghm
  • 2017-07-21 15:19
  • 1303

distcc: a fast, free distributed C/C++ compiler

http://distcc.googlecode.com/svn/trunk/doc/web/index.html distcc: a fast, free distributed C/C+...
  • rheostat
  • rheostat
  • 2012-06-23 08:14
  • 835

在WinDOWS X64下 Cuda NVCC 与 Intel C/C++ compiler联合使用的问题

Intel C/C++ Compiler 无疑是高性能编译器,基于Cuda的GPU计算能力非凡,在VS2013下集成二等用于摄影测量问题求解,图像处理等密集计算问题,无疑是技术控们的不二选择。 本...
  • sgz007
  • sgz007
  • 2015-04-27 22:33
  • 1368

online compiler web address for c/c++

1、http://codepad.org/  推荐星级:★★★★ 是否需注册:否(注册的话也很快,几秒钟而已)  优点:网页界面简洁,一目了然,适合手机浏览器。且支持C,C++,D,PHP,PY...
  • wuchuanpingstone
  • wuchuanpingstone
  • 2011-08-25 09:02
  • 1198
    个人资料
    • 访问:2599958次
    • 积分:39577
    • 等级:
    • 排名:第112名
    • 原创:1181篇
    • 转载:50篇
    • 译文:1篇
    • 评论:436条
    公告
    大海无边,网际无涯,本博客乃一小站,收集笔记与备忘录,供参考。基本没有原创,又基本全是原创。
    文章分类
    最新评论