Upgrade to Pro — share decks privately, control downloads, hide ads and more …

今日から使えるC11

 今日から使えるC11

C11の新機能の紹介です

NARUSE, Yui

May 11, 2016
Tweet

More Decks by NARUSE, Yui

Other Decks in Programming

Transcript

  1. C99ͷ৽ػೳ • ΠϯϥΠϯؔ਺ • Mixed declarations and code • enumએݴͰͷ৑௕ͳΧϯ

    Ϛ • Մม௕഑ྻ • ՄมҾ਺ϚΫϩ • //ίϝϯτ • __func__ • long long, intXX_t,boolͳͲ ͷܕ • snprintfͳͲͷؔ਺ • ܕ૯শ਺ֶؔ਺ (tgmath.h)
  2. C11 Changes • conditional (optional) features (including some that were

    previously mandatory) • support for multiple threads of execution including an improved memory sequencing model, atomic objects, and thread-local storage (<stdatomic.h> and <threads.h>) • additional floating-point characteristic macros (<float.h>) • querying and specifying alignment of objects (<stdalign.h>, <stdlib.h>) • Unicode characters and strings (<uchar.h>) (originally specified in ISO/IEC TR 19769:2004) • type-generic expressions • static assertions • anonymous structures and unions • no-return functions • macros to create complex numbers (<complex.h>) • support for opening files for exclusive access • removed the gets function (<stdio.h>) • added the aligned_alloc, at_quick_exit, and quick_exit functions (<stdlib.h>) • (conditional) support for bounds-checking interfaces (originally specified in • ISO/IEC TR 24731−1:2007) • (conditional) support for analyzability
  3. C11 • getsͷ࡟আ • Bounds-checking interfaces • fopen(“foo.txt”,”wx”) • _Alignas,

    alignof, aligned_alloc • _Noreturn • _Generic • threads.h • stdatomic.h • ແ໊ߏ଄ମɾແ໊union • _Static_assert
  4. getsͷ࡟আ • 2007೥ʹඇਪ঑ͱͳ͍͕͍ͬͯͨͭʹ࡟আ • char *gets(char *s); • ‘\n’·ͰಡΈࠐΉ •

    → ֬อ͢΂͖όοϑΝͷ௕͕͞ࣄલʹΘ͔Βͳ͍ • →όοϑΝΦʔόʔϥϯෆՄආ
  5. • abort_handler_s • asctime_s • bsearch_s • ctime_s • fopen_s

    • fprintf_s • freopen_s • fscanf_s • fwprintf_s • fwscanf_s • getenv_s • gets_s • gmtime_s • ignore_handler_s • L_tmpnam_s • localtime_s • mbsrtowcs_s • mbstowcs_s • memcpy_s • memmove_s • memset_s • printf_s • qsort_s • scanf_s • set_constraint_h andler_s • snprintf_s • snwprintf_s • sprintf_s • sscanf_s • strcat_s • strcpy_s • strerror_s • strerrorlen_s • strncat_s • strncpy_s • strnlen_s • strtok_s • swprintf_s • swscanf_s • TMP_MAX_S • tmpfile_s • tmpnam_s • vfprintf_s • vfscanf_s • vfwprintf_s • vfwscanf_s • vprintf_s • vscanf_s • vsnprintf_s • vsnwprintf_s • vsprintf_s • vsscanf_s • vsnprintf_s • vsnwprintf_s • vsprintf_s • vsscanf_s • vswprintf_s • vswscanf_s • vwprintf_s • vwscanf_s • wcrtomb_s • wcscat_s • wcscpy_s • wcsncat_s • wcsncpy_s • wcsnlen_s • wcsrtombs_s • wcstok_s • wcstombs_s • wctomb_s • wmemcpy_s • wmemmove_s • wprintf_s • wscanf_s
  6. threads.h εϨουAPI • pthread APIͷ໊લΛม͚͑ͨͩ • pthread_* → thrd_* •

    pthread_mutex_* → mtx_* • pthread_cond_* → cond_*
  7. ͦͷଞ • __builtin_constant_p • __builtin_unreachable • __builtin_types_compatible_p • __builtin_choose_expr •

    __builtin_expect • https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html • __has_builtin, __has_feature, __has_extension, __has_attribute, __has_include • http://clang.llvm.org/docs/LanguageExtensions.html
  8. • C99 • http://www.open-std.org/jtc1/sc22/wg14/www/docs/n869/ • http://www.open-std.org/JTC1/SC22/WG14/www/docs/n897.pdf • http://seclan.dll.jp/c99d/c99d00.htm • C11

    • http://www.open-std.org/JTC1/SC22/WG14/www/docs/ n1570.pdf • http://port70.net/~nsz/c/ • https://gcc.gnu.org/wiki/C11Status