-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