Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Semantic Issue - implicit declaration of function

Tags:

ios

appirater

I am using Appirater (https://github.com/arashpayan/appirater) to enable app ratings in my xcode project. Everything builds OK when using 'iOS Simulator' but when I use the 'iOS device' target to archive my project I get 2 build errors:

Semantic Issue: Implicit declaration of function 'SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO' is invalid in C99

Semantic Issue: Implicit declaration of function 'SYSTEM_VERSION_LESS_THAN' is invalid in C99

The relevant lines of code are in the Appirater.m file:

    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0") && SYSTEM_VERSION_LESS_THAN(@"7.1")) {
        reviewURL = [templateReviewURLiOS7 stringByReplacingOccurrencesOfString:@"APP_ID" withString:[NSString stringWithFormat:@"%@", _appId]];
    }

I found a set of macros that are very similar to these in How to check iOS version?

Any assistance would be appreciated.

like image 980
Allfocus Avatar asked May 22 '14 23:05

Allfocus


People also ask

What happens if a function is called without an explicit declaration?

In C90, if a function is called without an explicit declaration, the compiler is going to complain about the implicit declaration. Here is a small code that will give us an Implicit declaration of function error.

When is a function call implicitly declared?

From C89, Section 3.3.2.2: If the expression that precedes the parenthesized argument list in a function call consists solely of an identifier, and if no declaration is visible for this identifier, the identifier is implicitly declared exactly as if, in the innermost block containing the function call, the declaration appeared.

What is implicit declaration of function in C90?

In C90, if a function is called without an explicit declaration, the compiler is going to complain about the implicit declaration. Here is a small code that will give us an Implicit declaration of function error. Now the above code will give you an error of Implicit declaration.

Can I skip the declaration of a function in C99?

In the case of C99, you can skip the declaration but it will give us a small warning and it can be ignored but the definition of the function is important. This gives us the output:


1 Answers

Add these lines from your link to your .pch file. Clean and build. It should go away.

#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

More info: since the preprocessor cannot find them to do a find and replace for these macros, they pass through to the compiler where they look like C functions. The compiler cannot find them and gives you an error.

like image 169
rob5408 Avatar answered Oct 02 '22 05:10

rob5408