// filename:c2011-6-4-5-ex.c // original examples and/or notes: // (c) ISO/IEC JTC1 SC22 WG14 N1570, April 12, 2011 // http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf // C2011 6.4.5 String literals // compile and output mechanism: // (c) Ogawa Kiyoshi, kaizen@gifu-u.ac.jp, December.xx, 2013 // compile errors and/or wornings: // 1 (c) Apple LLVM version 4.2 (clang-425.0.27) (based on LLVM 3.2svn) // Target: x86_64-apple-darwin11.4.2 //Thread model: posix // (c) LLVM 2003-2009 University of Illinois at Urbana-Champaign. // 2 gcc-4.9 (GCC) 4.9.0 20131229 (experimental) // Copyright (C) 2013 Free Software Foundation, Inc. #include char * s; int main(void){ printf("\x12" "3");printf("\n"); printf("a" "b" L"c");printf("\n"); printf("%s",s);printf("\n"); printf("a" L"b" "c");printf("\n"); printf(L"a" "b" L"c");printf("\n"); printf(L"a" L"b" L"c");printf("\n"); printf("a" "b" u"c");printf("\n"); printf("a" u"b" "c");printf("\n"); printf(u"a" "b" u"c");printf("\n"); printf(u"a" u"b" u"c");printf("\n"); return printf("6.4.5 String literals \n"); } // warning and error LLVM3.2 c2011-6-4-5-ex.c:12:8: warning: incompatible pointer types passing 'int [4]' to parameter of type 'const char *' [-Wincompatible-pointer-types] printf("a" "b" L"c");printf("\n"); ^~~~~~~~~~~~ /usr/include/stdio.h:257:36: note: passing argument to parameter here int printf(const char * __restrict, ...) __printflike(1, 2); ^ c2011-6-4-5-ex.c:12:8: warning: format string should not be a wide string [-Wformat] printf("a" "b" L"c");printf("\n"); ^~~~~~~~~~~~ c2011-6-4-5-ex.c:14:8: warning: incompatible pointer types passing 'int [4]' to parameter of type 'const char *' [-Wincompatible-pointer-types] printf("a" L"b" "c");printf("\n"); ^~~~~~~~~~~~ /usr/include/stdio.h:257:36: note: passing argument to parameter here int printf(const char * __restrict, ...) __printflike(1, 2); ^ c2011-6-4-5-ex.c:14:8: warning: format string should not be a wide string [-Wformat] printf("a" L"b" "c");printf("\n"); ^~~~~~~~~~~~ c2011-6-4-5-ex.c:15:8: warning: incompatible pointer types passing 'int [4]' to parameter of type 'const char *' [-Wincompatible-pointer-types] printf(L"a" "b" L"c");printf("\n"); ^~~~~~~~~~~~~ /usr/include/stdio.h:257:36: note: passing argument to parameter here int printf(const char * __restrict, ...) __printflike(1, 2); ^ c2011-6-4-5-ex.c:15:8: warning: format string should not be a wide string [-Wformat] printf(L"a" "b" L"c");printf("\n"); ^~~~~~~~~~~~~ c2011-6-4-5-ex.c:16:8: warning: incompatible pointer types passing 'int [4]' to parameter of type 'const char *' [-Wincompatible-pointer-types] printf(L"a" L"b" L"c");printf("\n"); ^~~~~~~~~~~~~~ /usr/include/stdio.h:257:36: note: passing argument to parameter here int printf(const char * __restrict, ...) __printflike(1, 2); ^ c2011-6-4-5-ex.c:16:8: warning: format string should not be a wide string [-Wformat] printf(L"a" L"b" L"c");printf("\n"); ^~~~~~~~~~~~~~ c2011-6-4-5-ex.c:17:16: error: expected ')' printf("a" "b" u"c");printf("\n"); ^ c2011-6-4-5-ex.c:17:7: note: to match this '(' printf("a" "b" u"c");printf("\n"); ^ c2011-6-4-5-ex.c:18:12: error: expected ')' printf("a" u"b" "c");printf("\n"); ^ c2011-6-4-5-ex.c:18:7: note: to match this '(' printf("a" u"b" "c");printf("\n"); ^ c2011-6-4-5-ex.c:19:8: error: use of undeclared identifier 'u' printf(u"a" "b" u"c");printf("\n"); ^ c2011-6-4-5-ex.c:20:8: error: use of undeclared identifier 'u' printf(u"a" u"b" u"c");printf("\n"); ^ 8 warnings and 4 errors generated. // Warning GCC4.9 c2011-6-4-5-ex.c: In function 'main': c2011-6-4-5-ex.c:12:1: warning: passing argument 1 of 'printf' from incompatible pointer type [enabled by default] printf("a" "b" L"c");printf("\n"); ^ In file included from c2011-6-4-5-ex.c:8:0: /usr/include/stdio.h:257:6: note: expected 'const char * restrict' but argument is of type 'int *' int printf(const char * __restrict, ...) __printflike(1, 2); ^ c2011-6-4-5-ex.c:14:1: warning: passing argument 1 of 'printf' from incompatible pointer type [enabled by default] printf("a" L"b" "c");printf("\n"); ^ In file included from c2011-6-4-5-ex.c:8:0: /usr/include/stdio.h:257:6: note: expected 'const char * restrict' but argument is of type 'int *' int printf(const char * __restrict, ...) __printflike(1, 2); ^ c2011-6-4-5-ex.c:15:1: warning: passing argument 1 of 'printf' from incompatible pointer type [enabled by default] printf(L"a" "b" L"c");printf("\n"); ^ In file included from c2011-6-4-5-ex.c:8:0: /usr/include/stdio.h:257:6: note: expected 'const char * restrict' but argument is of type 'int *' int printf(const char * __restrict, ...) __printflike(1, 2); ^ c2011-6-4-5-ex.c:16:1: warning: passing argument 1 of 'printf' from incompatible pointer type [enabled by default] printf(L"a" L"b" L"c");printf("\n"); ^ In file included from c2011-6-4-5-ex.c:8:0: /usr/include/stdio.h:257:6: note: expected 'const char * restrict' but argument is of type 'int *' int printf(const char * __restrict, ...) __printflike(1, 2); ^ c2011-6-4-5-ex.c:17:1: warning: passing argument 1 of 'printf' from incompatible pointer type [enabled by default] printf("a" "b" u"c");printf("\n"); ^ In file included from c2011-6-4-5-ex.c:8:0: /usr/include/stdio.h:257:6: note: expected 'const char * restrict' but argument is of type 'short unsigned int *' int printf(const char * __restrict, ...) __printflike(1, 2); ^ c2011-6-4-5-ex.c:18:1: warning: passing argument 1 of 'printf' from incompatible pointer type [enabled by default] printf("a" u"b" "c");printf("\n"); ^ In file included from c2011-6-4-5-ex.c:8:0: /usr/include/stdio.h:257:6: note: expected 'const char * restrict' but argument is of type 'short unsigned int *' int printf(const char * __restrict, ...) __printflike(1, 2); ^ c2011-6-4-5-ex.c:19:1: warning: passing argument 1 of 'printf' from incompatible pointer type [enabled by default] printf(u"a" "b" u"c");printf("\n"); ^ In file included from c2011-6-4-5-ex.c:8:0: /usr/include/stdio.h:257:6: note: expected 'const char * restrict' but argument is of type 'short unsigned int *' int printf(const char * __restrict, ...) __printflike(1, 2); ^ c2011-6-4-5-ex.c:20:1: warning: passing argument 1 of 'printf' from incompatible pointer type [enabled by default] printf(u"a" u"b" u"c");printf("\n"); // ^ //In file included from c2011-6-4-5-ex.c:8:0: ///usr/include/stdio.h:257:6: note: expected 'const char * restrict' but argument is of type 'short unsigned int *' // int printf(const char * __restrict, ...) __printflike(1, 2); // ^ // output GCC 4.9 // 3 //a //(null) //a //a //a //a //a //a //a // 6.4.5 String literals