// filename:c2011-6-7-3-ex.c // original examples and/or notes: // (c) ISO/IEC JTC1 SC22 WG14 N1570, April 12, 2011 // C2011 6.7.3 Type qualifiers // compile and output mechanism: // (c) Ogawa Kiyoshi, kaizen@gifu-u.ac.jp, December.xx, 2013 // compile errors and/or wornings: // (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. #include int main(void) { // Example 1 extern const volatile int real_time_clock; // Example 2 const struct s { int mem; } cs = { 1 }; struct s ncs; // the object ncs is modifiable typedef int A[2][3]; const A a = {{4, 5, 6}, {7, 8, 9}}; // array of array of const int int *pi; const int *pci; ncs = cs; // valid cs = ncs; // violates modifiable lvalue constraint for = pi = &ncs.mem; // valid pi = &cs.mem; // violates type constraints for = pci = &cs.mem; // valid pi = a[0]; // invalid: a[0] has type ‘‘const int *’’ // Example 3 _Atomic volatile int *p; return printf("6.7.3 Type qualifiers %d %d\n",s.count,sp); } // output may be