Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No previous extern declaration for non-static variable 'FrameworkNameVersionString'

I created an iOS framework say CustomFramework and in the CustomFramework.h file created by Xcode has the following contents by default

#import <UIKit/UIKit.h>

//! Project version number for CustomFramework.
FOUNDATION_EXPORT double CustomFrameworkVersionNumber;

//! Project version string for CustomFramework.
FOUNDATION_EXPORT const unsigned char CustomFrameworkVersionString[];

// In this header, you should import all the public headers of your framework  using statements like #import <CustomFramework/PublicHeader.h>

When I build the project, I get these warnings

No previous extern declaration for non-static variable 'CustomFrameworkVersionNumber'
No previous extern declaration for non-static variable 'CustomFrameworkVersionString'

Any idea why the default framework creation would give these warnings ?

like image 250
ArdenDev Avatar asked Feb 14 '15 01:02

ArdenDev


1 Answers

In C family languages this is caused by a variable not explicitly being defined as static or being declared in a header file as extern.

You have three options for dealing with it.

  1. Place the static keyword in front of the definition.

    static FOUNDATION_EXPORT double CustomFrameworkVersionNumber;
    
    static FOUNDATION_EXPORT const unsigned char CustomFrameworkVersionString[];
    
  2. Create a separate header file with an extern definition for each variable.

  3. Suppress the warning with -Wmissing-variable-declarations

This question is similar to this question.

like image 117
Nathaniel Johnson Avatar answered Nov 17 '22 09:11

Nathaniel Johnson