@@ -383,19 +383,21 @@ <h3 id="objc_objs-cast">Internal Objective-C types</h3>
383
383
instead of the internal types.</ p >
384
384
385
385
<!-- ======================================================================= -->
386
- < h3 id ="c_variables-class "> C variables in @class or @protocol</ h3 >
386
+ < h3 id ="c_variables-class "> C variables in @interface or @protocol</ h3 >
387
387
<!-- ======================================================================= -->
388
388
389
- < p > GCC allows declaration of C variables in a @class or @protocol, but not
390
- C functions. Clang does not allow variable or C function declarations. External
391
- declarations, however, is allowed. Variables may only be declared in an
392
- @implementation.
389
+ < p > GCC allows the declaration of C variables in
390
+ an < code > @interface</ code > or < code > @protocol</ code >
391
+ declaration. Clang does not allow variable declarations to appear
392
+ within these declarations unless they are marked < code > extern</ code > .</ p >
393
+
394
+ < p > Variables may still be declared in an @implementation.</ p >
393
395
394
396
< pre >
395
397
@interface XX
396
- int x ; // not allowed in clang
397
- int one= 1; // not allowed in clang
398
- extern int OK;
398
+ int a ; // not allowed in clang
399
+ int b = 1; // not allowed in clang
400
+ extern int c; // allowed
399
401
@end
400
402
401
403
</ pre >
@@ -431,7 +433,7 @@ <h3 id="vla">Variable-length arrays</h3>
431
433
simple as changing < tt > int size = ...;</ tt > to < tt > const int size
432
434
= ...;</ tt > (if the definition of < tt > size</ tt > is a compile-time
433
435
integral constant);</ li >
434
- < li > use an < tt > std::string</ tt > instead of a < tt > char []</ tt > ;</ li >
436
+ < li > use < tt > std::string</ tt > instead of a < tt > char []</ tt > ;</ li >
435
437
< li > use < tt > std::vector</ tt > or some other suitable container type;
436
438
or</ li >
437
439
< li > allocate the array on the heap instead using < tt > new Type[]</ tt > -
0 commit comments