const-cfstring-2.m
来自「Mac OS X 10.4.9 for x86 Source Code gcc」· M 代码 · 共 27 行
M
27 行
/* APPLE LOCAL file constant CFStrings *//* Test the -Wnonportable-cfstrings option, which should give warnings if non-ASCII characters are embedded in constant CFStrings. This will only work on MacOS X 10.2 and later. *//* Developed by Ziemowit Laski <zlaski@apple.com>. *//* { dg-do compile { target *-*-darwin* } } *//* { dg-options "-fconstant-cfstrings -Wnonportable-cfstrings" } */#import <Foundation/NSString.h>#import <CoreFoundation/CFString.h>#ifndef __CONSTANT_CFSTRINGS__#error The -fconstant-cfstrings option is not functioning properly#endifvoid foo(void) { NSString *s1 = @"Compile-time string literal"; CFStringRef s2 = CFSTR("Compile-time string literal"); NSString *s3 = @"Non-ASCII literal - \222"; /* { dg-warning "non-ASCII character in CFString literal" } */ CFStringRef s4 = CFSTR("\222 - Non-ASCII literal"); /* { dg-warning "non-ASCII character in CFString literal" } */ CFStringRef s5 = CFSTR("Non-ASCII (\222) literal"); /* { dg-warning "non-ASCII character in CFString literal" } */ NSString *s6 = @"\0Embedded NUL"; /* { dg-warning "embedded NUL in CFString literal" } */ CFStringRef s7 = CFSTR("Embedded \0NUL"); /* { dg-warning "embedded NUL in CFString literal" } */ CFStringRef s8 = CFSTR("Embedded NUL\0"); /* { dg-warning "embedded NUL in CFString literal" } */}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?