-std=c++11 -std=gnu++11 c++0x c++11


uint8_t的后缀_t的意思到底表示什么?

它就是一个结构的标注,可以理解为type/typedef的缩写,表示它是通过typedef定义的,而不是其它数据类型。

uint8_t,uint16_t,uint32_t等都不是什么新的数据类型,它们只是使用typedef给类型起的别名,新瓶装老酒的把戏。不 过,不要小看了typedef,它对于你代码的维护会有很好的作用。比如C中没有bool,于是在一个软件中,一些程序员使用int,一些程序员使用 short,会比较混乱,最好就是用一个typedef来定义,如:
typedef char bool;

 

 

CMAKE_CXX_COMPILER_ID

 

https://www.zhihu.com/question/20141092

http://www.keil.com/support/man/docs/armcc/armcc_chr1359124965274.htm


The old -std=c++0x is only needed for older compiler versions that did not support -std=c++11 and they chose that name to express the preliminary and unstable nature of features (and the ABI) of the then upcoming C++11 (and when it was still unclear whether that would eventually become C++10 or C++12). They changes some of the details adapting to the changing working drafts of the standard at the time before the C++11 standard was officially released.

If your compiler supports -std=c++11, there is no reason to use -std=c++0x. Concerning compatibility: There might even be differences and incompatibilities, but these are not just bound to the use of -std=c++0x, but to specific versions of the compiler. When the compiler supports both, they should be identical.

豆瓣: -std=c++11 -std=c++0x
 
 
上一个版本的C++国际标准是2003年发布的,所以叫C++ 03。
然后C++国际标准委员会在研究C++ 03的下一个版本的时候,一开始计划是07年发布,所以最初这个标准叫C++ 07。
但是到06年的时候,官方觉得07年肯定完不成C++ 07,而且官方觉得08年可能也完不成。最后干脆叫C++ 0x。x的意思是不知道到底能在07还是08还是09年完成。
结果2010年的时候也没完成,最后在2011年终于完成了C++标准。所以最终定名为C++11。


GNU provides many extensions to the C and C++ languages
 

参考 C++ Standards Support in GCC 

This mode can be selected with the -std=c++11 command-line flag, or -std=gnu++11 to enable GNU extensions as well.

-std=c++11,支持C++11标准;

-std=gnu++11,支持C++11标准和GNU扩展特性;

比如,GNU extensions to the C and C++ languages
---------------------

https://gcc.gnu.org/projects/cxx-status.html

C++11 Support in GCC

GCC 4.8.1 was the first feature-complete implementation of the 2011 C++ standard, previously known as C++0x.

This mode can be selected with the -std=c++11 command-line flag, or -std=gnu++11 to enable GNU extensions as well.

  • Clang是C 编译器
  • Clang++是 C++ 编译器( 像 G++ 是 C++ 编译器,而gcc是一个C 编译器)
 
 
=============
  • -std=  (c++11/gnu++11)

      -std指编译器可支持的C++标准类型。-std=c++98 ;  -std=c++11,支持C++11标准; -std=gnu++11,支持C++11标准和GNU扩展特性;

    比如,GNU extensions to the C and C++ languages

 

  • -stdlib= (libstdc++/libc++ )

     -stdlib指编译器提供的标准C ++库类型。gcc编译器没有像 -stdlib 这样的命令行选项。 。LLVM clang编译器可以。 这是因为clang为您提供链接LLVM标准C ++库( libc ++ )或GNU标准C ++库( libstdc ++ ),而gcc只支持 libstdc ++ 。

     简单说就是两个都是 C++ 标准库,libc++ 是针对 Clang 编译器特别重写的 C++ 标准库,而 libstdc++ 则是 GCC 的对应 C++ 标准库。

     LLVM clang编译程序范例指定CXXFLAGS = -std=c++11 -stdlib=libstdc++

 

-stdlib=libstdc++ 不是有效的gcc标志

man gcc, man g++都不会找到-stdlib=的选项,只有-std=的选项,因为GNU gcc的stdlib默认都是libstdc++

 

在Linux上:通常,所有常用的Linux发行版默认使用libstdc ++,所有现代版本的GCC都附带一个支持C ++ 11的libstdc ++。如果要在此处编译c ++ 11代码,请使用以下方法之一:

  • g++ -std=c++11 input.cxx -o a.out
  • g++ -std=gnu++11 input.cxx -o a.out

在小牛队之前的OS X上: g++ 实际上是别名 clang++ Apple的旧版libstdc ++是默认版本。您可以通过传递使用libc ++(包括c ++ 11库支持) -stdlib=libc++。如果要在此处编译c ++ 11代码,请使用以下方法之一:

  • g++ -std=c++11 -stdlib=libc++ input.cxx -o a.out
  • g++ -std=gnu++11 -stdlib=libc++ input.cxx -o a.out
  • clang++ -std=c++11 -stdlib=libc++ input.cxx -o a.out
  • clang++ -std=gnu++11 -stdlib=libc++ input.cxx -o a.out

在小牛队以来的OS X上:libc ++是默认值。您可以通过传递Apple的旧版本的libstdc ++(不包括c ++ 11库支持) -stdlib=libstdc++

  • clang++ -std=c++11 input.cxx -o a.out
  • clang++ -std=gnu++11 input.cxx -o a.out
 
 

LLVM的libc++ is an implementation of the C++ standard library, targeting C++11, C++14 and above.
export CC=clang CXX=clang++
$ clang++ -stdlib=libc++ test.cpp
$ clang++ -std=c++11 -stdlib=libc++ test.cpp 【】
http://libcxx.llvm.org/
其他的C++库
like Apache's libstdcxx, GNU's libstdc++, STLport, etc
https://www.gnu.org/software/gcc/projects/cxx-status.html
GNU GCC的4.7,4.8版本才开始支持c++11
/home/mylinux/pepper_47//toolchain/linux_x86_glibc/bin/x86_64-nacl-gcc -v
显示
gcc version 4.4.3 20150713 (Native Client 9ff1dc0c05b45941b86bed303a87a9eac17192ea, Git Commit f80d6b9ee7f94755c697ffb7194fb01dd0c537dd) (GCC)
所以x86_64-nacl-gcc不支持c++11【】

 
===============

【glibc 和 libc】 

glibc 和 libc 都是 Linux 下的 C 函数库。 
libc 是 Linux 下的 ANSI C 函数库;glibc 是 Linux 下的 GUN C 函数库。 

ANSI C 和 GNU C 有什么区别呢? 

       ANSI C 函数库是基本的 C 语言函数库,包含了 C 语言最基本的库函数。这个库可以根据头文件划分为 15 个部分,其中包括: 

  1. <ctype.h>:包含用来测试某个特征字符的函数的函数原型,以及用来转换大小写字母的函数原型;
  2. <errno.h>:定义用来报告错误条件的宏;
  3. <float.h>:包含系统的浮点数大小限制;
  4. <math.h>:包含数学库函数的函数原型;
  5. <stddef.h>:包含执行某些计算 C 所用的常见的函数定义;
  6. <stdio.h>:包含标准输入输出库函数的函数原型,以及他们所用的信息;
  7. <stdlib.h>:包含数字转换到文本,以及文本转换到数字的函数原型,还有内存分配、随机数字以及其他实用函数的函数原型;
  8. <string.h>:包含字符串处理函数的函数原型;
  9. <time.h>:包含时间和日期操作的函数原型和类型;
  10. <stdarg.h>:包含函数原型和宏,用于处理未知数值和类型的函数的参数列表;
  11. <signal.h>:包含函数原型和宏,用于处理程序执行期间可能出现的各种条件;
  12. <setjmp.h>:包含可以绕过一般函数调用并返回序列的函数的原型,即非局部跳转;
  13. <locale.h>:包含函数原型和其他信息,使程序可以针对所运行的地区进行修改。
  14. 地区的表示方法可以使计算机系统处理不同的数据表达约定,如全世界的日期、时间、美元数和大数字;
  15. <assert.h>:包含宏和信息,用于进行诊断,帮助程序调试。
上述库函数在其各种支持 C 语言的 IDE 中都是有的。 

       GNU C 函数库是一种类似于第三方插件的东西。由于 Linux 是用 C 语言写的,所以 Linux 的一些操作是用 C 语言实现的,因此,GUN 组织开发了一个 C 语言的库 以便让我们更好的利用 C 语言开发基于 Linux 操作系统的程序。不过现在的不同的 Linux 的发行版本对这两个函数库有不同的处理方法,有的可能已经集成在同一个库里了。 

glibc下载地址:http://mirror.hust.edu.cn/gnu/

glibc是linux下面c标准库的实现,即GNU C Library。glibc本身是GNU旗下的C标准库,后来逐渐成为了Linux的标准c库,而Linux下原来的标准c库Linux libc逐渐不再被维护。Linux下面的标准c库不仅有这一个,如uclibc(https://www.uclibc.org/)、klibc,以及上面被提到的Linux libc,但是glibc无疑是用得最多的。glibc在/lib目录下的.so文件为libc.so.6。

 



【glibc 和 glib】 

      错误观点:glib 前面有个 "g" ,所以认为 glib 是 GNU 的东东;同时认为 glibc 是 glib 的一个子集。 

      其实,glib 和 glibc 基本上没有太大联系,可能唯一的共同点就是,其都是 C 编程需要调用的库而已。 
glib 是 Gtk+ 库和 Gnome 的基础。glib 可以在多个平台下使用,比如 Linux、Unix、Windows 等。glib 为许多标准的、常用的 C 语言结构提供了相应的替代物。 

glib是GTK+的基础库,它由基础类型、对核心应用的支持、实用功能、数据类型和对象系统五个部分组成,可以在[http://www.gtk.org gtk网站]下载其源代码。是一个综合用途的实用的轻量级的C程序库,它提供C语言的常用的数据结构的定义、相关的处理函数,有趣而实用的宏,可移植的封装和一些运行时机能,如事件循环、线程、动态调用、对象系统等的API。GTK+是可移植的,当然glib也是可移植的,你可以在linux下,也可以在windows下使用它。使用gLib2.0(glib的2.0版本)编写的应用程序,在编译时应该在编译命令中加入pkg-config --cflags --libs glib-2.0,如:

gcc  pkg-config --cflags --libs glib-2.0 hello.c -o hello

使用glib最有名的就是GNOME了。

 

【官方说明】

 

Glib

GLib is a general-purpose utility library, which provides many useful data types, macros, type conversions, string utilities, file utilities, a main loop abstraction, and so on. It works on many UNIX-like platforms, Windows, OS/2 and BeOS. GLib is released under the GNU Library General Public License (GNU LGPL).
The general policy of GLib is that all functions are invisibly threadsafe with the exception of data structure manipulation functions, where, if you have two threads manipulating the same data structure, they must use a lock to synchronize their operation.
GLib is the low-level core library that forms the basis for projects such as GTK+ and GNOME. It provides data structure handling for C, portability wrappers, and interfaces for such runtime functionality as an event loop, threads, dynamic loading, and an object system. 

Glibc 
Overview: 
Any Unix-like operating system needs a C library: the library which defines the ``system calls'' and other basic facilities such as open, malloc, printf, exit... 
The GNU C Library is used as the C library in the GNU systems and most systems with the Linux kernel.
Project Goals:  
The GNU C Library is primarily designed to be a portable and high performance C library. It follows all relevant standards including ISO C11 and POSIX.1-2008. It is also internationalized and has one of the most complete internationalization interfaces known.
History: 
The history of Unix and various standards determine much of the interface of the C library. In general the GNU C Library supports the ISO C and POSIX standards. We also try to support the features of popular Unix variants (including BSD and System V) when those do not conflict with the standards. Different compatibility modes (selectable when you compile an application) allow the peaceful coexistence of compatibility support for different varieties of Unix. 

【其他说法】 

libc 实际上是一个泛指。凡是符合实现了 C 标准规定的内容,都是一种 libc 。
glibc 是 GNU 组织对 libc 的一种实现。它是 unix/linux 的根基之一。
微软也有自己的 libc 实现,叫 msvcrt 。
嵌入式行业里还常用 uClibc ,是一个迷你版的 libc 。

【yasi】

libc, glibc在一个层次,都是C的标准实现库,是操作系统级别的基石之一。

glib是用C写的一些utilities,即C的工具库,和libc/glibc没有关系。

转自:http://blog.csdn.net/yasi_xi/article/details/9899599

 
函数分三种:
1.ISO C 标准的
2.POSIX 标准的
3.系统自己扩展的(fopen64/kqueue)
第一种可以认为是跨平台的,第二种可以认为是跨 Unix/Linux 的,第三种是系统特定的。 
 
 
 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM