Can local and register variables be declared extern?

Local variables can be declared extern in some cases Let’s read the C99 N1256 standard draft. The standard calls “local variables” as having “block scope”. 6.7.1/5 “Storage-class specifiers” says: The declaration of an identifier for a function that has block scope shall have no explicit storage-class specifier other than extern. Then for what it means … Read more

How does extern work in C#?

Consider reading section 10.6.7 of the C# specification, which answers many of your questions. I reproduce part of it here for your convenience: When a method declaration includes an extern modifier, that method is said to be an external method. External methods are implemented externally, typically using a language other than C#. Because an external … Read more

Forward-declare enum in Objective-C

Most recent way (Swift 3; May 2017) to forward declare the enum (NS_ENUM/NS_OPTION) in objective-c is to use the following: // Forward declaration for XYZCharacterType in other header say XYZCharacter.h typedef NS_ENUM(NSUInteger, XYZCharacterType); // Enum declaration header: “XYZEnumType.h” #ifndef XYZCharacterType_h #define XYZCharacterType_h typedef NS_ENUM(NSUInteger, XYZEnumType) { XYZCharacterTypeNotSet, XYZCharacterTypeAgent, XYZCharacterTypeKiller, }; #endif /* XYZCharacterType_h */`

Does a declaration using “auto” match an extern declaration that uses a concrete type specifier?

There’s surprisingly little in the standard about this. About all we hear about redeclaration is: [C++11: 3.1/1]: A declaration (Clause 7) may introduce one or more names into a translation unit or redeclare names introduced by previous declarations. [..] and the only relevant part of auto‘s semantics: [C++11: 7.1.6.4/3]: Otherwise, the type of the variable … Read more