Share
Embed
Transcript
21 slides
-
C99ͷ৽ػೳ • ΠϯϥΠϯؔ • Mixed declarations and code • enumએݴͰͷͳΧϯ
Ϛ • Մมྻ • ՄมҾϚΫϩ • //ίϝϯτ • __func__ • long long, intXX_t,boolͳͲ ͷܕ • snprintfͳͲͷؔ • ܕ૯শֶؔ (tgmath.h) -
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 -
C11 • getsͷআ • Bounds-checking interfaces • fopen(“foo.txt”,”wx”) • _Alignas,
alignof, aligned_alloc • _Noreturn • _Generic • threads.h • stdatomic.h • ແ໊ߏମɾແ໊union • _Static_assert -
getsͷআ • 2007ʹඇਪͱͳ͍͕͍ͬͯͨͭʹআ • char *gets(char *s); • ‘\n’·ͰಡΈࠐΉ •
→ ֬อ͖͢όοϑΝͷ͕͞ࣄલʹΘ͔Βͳ͍ • →όοϑΝΦʔόʔϥϯෆՄආ -
rsize_t • sizeof(rsize_t) == sizeof(size_t) • RSIZE_MAX(SIZE_MAX >>1)࠷େ͖ͳ ΦϒδΣΫτͷαΠζΛఆٛ͢Δ͜ͱ͕ਪ •
https://www.jpcert.or.jp/sc-rules/c-int01-c.html -
• 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 -
fopen( , “x”) • open(2) (POSIX)ʹ͋ΔO_EXCLͷɺfopen൛ • wx, wbx, w+x,
w+bx, wb+x • ϑΝΠϧ͕طʹ͋ͬͨΒΤϥʔʹ͢Δ -
ΞϥΠϝϯτؔ࿈ • _Alignas (alignas): __attribute__((align)) Ͱ͢ • _Alignof (alignof): __alignof__Ͱ͢
• ׅހͷ໊લ stdalign.h • ͲͪΒGCC 2.95Ͱ͢Ͱʹ͋Δ -
threads.h εϨουϩʔΧϧετϨʔδ • _Thread_localهԱҬࢦఆࢠ (__thread) • ม໊ʹ͚ͭΔ͚ͩͰεϨουϩʔΧϧʹͳΔ • tss_create/tss_delete/tss_set/tss_get •
POSIXͷTLSΈ͍ͨͳAPI͋Δ • pthread_key_create/pthread_key_delete/pthread_setspecific/ pthread_getspecific -
threads.h εϨουAPI • pthread APIͷ໊લΛม͚͑ͨͩ • pthread_* → thrd_* •
pthread_mutex_* → mtx_* • pthread_cond_* → cond_* -
·ͱΊ • C99จ๏ͷมߋ͕ଟ͔ͬͨ • Ͱ࠷ۙͷ͍͍ͩͨαϙʔτ͍ͯ͠Δ • C11จ๏ͷมߋগͳ͍ • จ๏ͷมߋΛΘͳͯ͘ಉ͜͡ͱ͕ग़དྷΔ •
ͭ·ΓɺC11ͷػೳ(configureͱ͔Ͱ͕ΜΕ)ࠓ͔ Β͑Δʂ -
ͦͷଞ • __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 -
• 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