函数“...”的隐式声明在C99上无效 [英] Implicit declaration of function '...' is invalid on C99

查看:2974
本文介绍了函数“...”的隐式声明在C99上无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仍在使用名为Cruzia的iPhone应用程序,现在想知道为什么我要在ViewController.m和三个错误中都发出这两个警告,所有的Apple Mach-O链接器错误。如果你能指出我的方向一些修复,我会非常感激。我已经在我的viewcontroller.m的副本中注释了以下警告:

  #importCIAViewController.h

@interface CIAViewController()


@end

@implementation CIAViewController




- (IBAction)press {
cruzia.hidden = 0;
textarea.hidden = 0;
playbtn.hidden = 1;
tutorialbtn.hidden = 1;
optionsbtn.hidden = 1;
trainingbtn.hidden = 1;
back.hidden = 0;
cruzia.text = @Play;
textarea.text = @你好,你在玩Cruzia游戏!

//声明默认值它不在您的视图控制器中的其他地方声明
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];

// stringForKey方法返回一个String而不是一个布尔值
//但是,如果你只是想检查一个值是否存在,那么它意味着你正在检查存在
//如果没有值,那么它将返回nil并且语句将失败
//你在圆括号之外有一个非法语句== YES
if([defaults stringForKey: kMusic]){
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle,(CFStringRef)@click,CFSTR(wav),NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef,& soundID);
AudioServicesPlaySystemSound(soundID); }

}


- (IBAction)press2 {
cruzia.hidden = 0;
textarea.hidden = 0;
playbtn.hidden = 1;
tutorialbtn.hidden = 1;
optionsbtn.hidden = 1;
trainingbtn.hidden = 1;
back.hidden = 0;
cruzia.text = @Tutorial;
textarea.text = @欢迎!您正在观看Cruzia教程!
//声明默认值它不在您的视图控制器中的其他地方声明
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];

// stringForKey方法返回一个String而不是一个布尔值
//但是,如果你只是想检查一个值是否存在,那么它意味着你正在检查存在
//如果没有值,那么它将返回nil并且语句将失败
//你在圆括号之外有一个非法语句== YES
if([defaults stringForKey: kMusic]){
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef
soundFileURLRef = CFBundleCopyResourceURL(mainBundle,(CFStringRef)@click,CFSTR(WAV),NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef,& soundID);
AudioServicesPlaySystemSound(soundID); }
}

- (IBAction)press3 {
cruzia.hidden = 0;
textarea.hidden = 0;
playbtn.hidden = 1;
tutorialbtn.hidden = 1;
optionsbtn.hidden = 1;
trainingbtn.hidden = 1;
back.hidden = 0;
cruzia.text = @选项;
textarea.text = @你好!你点击了选项,可悲的是,你需要打开Settngs,去Cruzia地区获得游戏的大部分选项。
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef
soundFileURLRef = CFBundleCopyResourceURL(mainBundle,(CFStringRef)@click,CFSTR(WAV),NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef,& soundID);
AudioServicesPlaySystemSound(soundID);
}

- (IBAction)press4 {
cruzia.hidden = 0;
textarea.hidden = 0;
playbtn.hidden = 1;
tutorialbtn.hidden = 1;
optionsbtn.hidden = 1;
trainingbtn.hidden = 1;
back.hidden = 0;
cruzia.text = @训练;
textarea.text = @这是训练区域,你可以在这里提高你的Cruzia技能!
//声明默认值它不在您的视图控制器中的其他地方声明
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];

// stringForKey方法返回一个String而不是一个布尔值
//但是,如果你只是想检查一个值是否存在,那么它意味着你正在检查存在
//如果没有值,那么它将返回nil并且语句将失败
//你在圆括号之外有一个非法语句== YES
if([defaults stringForKey: kMusic]){
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle,(CFStringRef)@click,CFSTR(WAV),NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef,& soundID);
AudioServicesPlaySystemSound(soundID); }
}

- (IBAction)press5 {
cruzia.hidden = 0;
textarea.hidden = 0;
playbtn.hidden = 0;
tutorialbtn.hidden = 0;
optionsbtn.hidden = 0;
trainingbtn.hidden = 0;
back.hidden = 1;
cruzia.text = @Cruzia;
textarea.text = @;
//声明默认值它不在您的视图控制器中的其他地方声明
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];

// stringForKey方法返回一个String而不是一个布尔值
//但是,如果你只是想检查一个值是否存在,那么它就暗示你正在检查存在
//如果没有值,那么它将返回nil并且语句将失败
//你在圆括号之外有一个非法语句== YES
if([defaults stringForKey: kMusic]){
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle,(CFStringRef)@click,CFSTR(WAV),NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef,& soundID);
AudioServicesPlaySystemSound(soundID); }

}

- (void)viewDidLoad
{
textarea.hidden = 1;
playbtn.hidden = 0;
tutorialbtn.hidden = 0;
optionsbtn.hidden = 0;
trainingbtn.hidden = 0;
back.hidden = 1;
cruzia.text = @Cruzia;
[super viewDidLoad];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateSettings :)
name:
NSUserDefaultsDidChangeNotification object:nil];

[self setupDefaults];
}

- (void)viewDidUnload
{

[super viewDidUnload];

[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidFinishLaunchingNotification object:nil];
}

- (void)setupDefaults {
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];


NSString * violenceValue = [defaults stringForKey:kViolenceMode];

if(violenceValue == nil){
NSString * pathStr = [[NSBundle mainBundle] bundlePath];
NSString * settingsBundlePath = [pathStr stringByAppendingPathComponent:@Settings.bundle];
NSString * finalPath = [settingsBundlePath stringByAppendingPathComponent:@Root.plist];

NSDictionary * settingsDictionary = [NSDictionary dictionaryWithContentsOfFile:finalPath];
NSArray * prefSpecifierArray = [settingsDictionary objectForKey:@PreferenceSpecifiers];


NSString * isMusicOn,* isSoundOn;

NSDictionary * prefItem;

for(prefSpecifierArray中的prefItem){
NSString * keyValue = [prefItem objectForKey:@Key];
id defaultValue = [prefItem objectForKey:@DeafultValue];

if([keyValue isEqualToString:kSound])
{
isSoundOn = defaultValue;
}
else if([keyValue isEqualToString:kMusic])
{
isMusicOn = defaultValue;
}

NSDictionary * appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:isSoundOn,kSound,isMusicOn,kMusic,nil];

[defaults registerDefaults:appDefaults];
[defaults synchronize];

}

}

}



@end

这里是一个链接到截图的地方,我得到其他错误与打开调试和输出面板。 / p>

>



再次感谢
-George

解决方案

符号缺失:



AudioServicesCreateSystemSoundID
and AudioServicesPlaySystemSound



简单的解决方案是,您需要添加AudioToolbox框架到您的项目。


I am still working on an iPhone app called Cruzia and am now wondering why I am geting these two warnings, both in ViewController.m and three errors, all an Apple Mach-O Linker Error. If you can point me in the direction of some fixes I would be very appreciative. I have commented the warnings out below in a copy of my viewcontroller.m:

#import "CIAViewController.h"

@interface CIAViewController()


@end

@implementation CIAViewController




-(IBAction)press {
    cruzia.hidden = 0;
    textarea.hidden = 0;
    playbtn.hidden = 1;
    tutorialbtn.hidden = 1;
    optionsbtn.hidden = 1;
    trainingbtn.hidden = 1;
    back.hidden = 0;
    cruzia.text = @"Play";
    textarea.text = @"Hello! You are playing the game of Cruzia!";

        // declare defaults it is not declared elsewhere within your view controller
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

        // The stringForKey method returns a String and not a Boolean value
        // However, if you just want to check if a value exists then it is implied you are checking for existence
        // If there is no value then it will return nil and statement will fail
        // You had "== YES" outside of the parenthesis which is an illegal statement
        if ([defaults stringForKey:kMusic])  {
            CFBundleRef mainBundle = CFBundleGetMainBundle();
            CFURLRef soundFileURLRef;
            soundFileURLRef =CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"click",                     CFSTR ("wav"), NULL);
            UInt32 soundID;
            AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
            AudioServicesPlaySystemSound(soundID); }

}


-(IBAction)press2 {
    cruzia.hidden = 0;
    textarea.hidden = 0;
    playbtn.hidden = 1;
    tutorialbtn.hidden = 1;
    optionsbtn.hidden = 1;
    trainingbtn.hidden = 1;
    back.hidden = 0;
    cruzia.text = @"Tutorial";
    textarea.text = @"Welcome! You are watching the Cruzia tutorial!";
    // declare defaults it is not declared elsewhere within your view controller
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

    // The stringForKey method returns a String and not a Boolean value
    // However, if you just want to check if a value exists then it is implied you are checking for existence
    // If there is no value then it will return nil and statement will fail
    // You had "== YES" outside of the parenthesis which is an illegal statement
    if ([defaults stringForKey:kMusic])  {
        CFBundleRef mainBundle = CFBundleGetMainBundle();
        CFURLRef soundFileURLRef;
        soundFileURLRef =CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"click",                     CFSTR ("WAV"), NULL);
        UInt32 soundID;
        AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
        AudioServicesPlaySystemSound(soundID); }
}

-(IBAction)press3 {
    cruzia.hidden = 0;
    textarea.hidden = 0;
    playbtn.hidden = 1;
    tutorialbtn.hidden = 1;
    optionsbtn.hidden = 1;
    trainingbtn.hidden = 1;
    back.hidden = 0;
    cruzia.text = @"Options";
    textarea.text = @"Hello! You have clicked Options. Sadly, you need to open Settngs and go to the Cruzia area to get most of the options of the game.";
    CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef soundFileURLRef;
    soundFileURLRef =CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"click", CFSTR ("WAV"), NULL);
    UInt32 soundID;
    AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
    AudioServicesPlaySystemSound(soundID);
}

-(IBAction)press4 {
    cruzia.hidden = 0;
    textarea.hidden = 0;
    playbtn.hidden = 1;
    tutorialbtn.hidden = 1;
    optionsbtn.hidden = 1;
    trainingbtn.hidden = 1;
    back.hidden = 0;
    cruzia.text = @"Training";
    textarea.text = @"This is the training area. You can improve your Cruzia skills here!";
    // declare defaults it is not declared elsewhere within your view controller
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

    // The stringForKey method returns a String and not a Boolean value
    // However, if you just want to check if a value exists then it is implied you are checking for existence
    // If there is no value then it will return nil and statement will fail
    // You had "== YES" outside of the parenthesis which is an illegal statement
    if ([defaults stringForKey:kMusic])  {
        CFBundleRef mainBundle = CFBundleGetMainBundle();
        CFURLRef soundFileURLRef;
        soundFileURLRef =CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"click",                     CFSTR ("WAV"), NULL);
        UInt32 soundID;
        AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
        AudioServicesPlaySystemSound(soundID); }
}

-(IBAction)press5 {
    cruzia.hidden = 0;
    textarea.hidden = 0;
    playbtn.hidden = 0;
    tutorialbtn.hidden = 0;
    optionsbtn.hidden = 0;
    trainingbtn.hidden = 0;
    back.hidden = 1;
    cruzia.text = @"Cruzia";
    textarea.text = @"";
    // declare defaults it is not declared elsewhere within your view controller
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

    // The stringForKey method returns a String and not a Boolean value
    // However, if you just want to check if a value exists then it is implied you are checking for existence
    // If there is no value then it will return nil and statement will fail
    // You had "== YES" outside of the parenthesis which is an illegal statement
    if ([defaults stringForKey:kMusic])  {
        CFBundleRef mainBundle = CFBundleGetMainBundle();
        CFURLRef soundFileURLRef;
        soundFileURLRef =CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"click",                     CFSTR ("WAV"), NULL);
        UInt32 soundID;
        AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
        AudioServicesPlaySystemSound(soundID); }

}

- (void)viewDidLoad
{
    textarea.hidden = 1;
    playbtn.hidden = 0;
    tutorialbtn.hidden = 0;
    optionsbtn.hidden = 0;
    trainingbtn.hidden = 0;
    back.hidden = 1;
    cruzia.text = @"Cruzia";
    [super viewDidLoad];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateSettings:)
                                                name:
     NSUserDefaultsDidChangeNotification object:nil];

    [self setupDefaults];
}

- (void)viewDidUnload
{

    [super viewDidUnload];

    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidFinishLaunchingNotification object:nil];
}

-(void) setupDefaults {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];


    NSString *violenceValue = [defaults stringForKey:kViolenceMode];

    if ( violenceValue == nil ) {
        NSString *pathStr = [[NSBundle mainBundle] bundlePath];
        NSString *settingsBundlePath = [pathStr stringByAppendingPathComponent:@"Settings.bundle"];
        NSString *finalPath = [settingsBundlePath stringByAppendingPathComponent:@"Root.plist"];

        NSDictionary *settingsDictionary = [NSDictionary dictionaryWithContentsOfFile:finalPath];
        NSArray *prefSpecifierArray = [settingsDictionary objectForKey:@"PreferenceSpecifiers"];


        NSString *isMusicOn, *isSoundOn;

        NSDictionary *prefItem;

        for (prefItem in prefSpecifierArray) {
            NSString *keyValue = [prefItem objectForKey:@"Key"];
            id defaultValue = [prefItem objectForKey:@"DeafultValue"];

            if ([keyValue isEqualToString:kSound])
            {
                isSoundOn = defaultValue;
            }
            else if ([keyValue isEqualToString:kMusic])
            {
                isMusicOn = defaultValue;
            }

            NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:                                  isSoundOn, kSound, isMusicOn, kMusic, nil];

            [defaults registerDefaults:appDefaults];
            [defaults synchronize];

        }

    }

}



@end

And here is a link to a screenshot of the place I am getting the other errors with the Debug and Output panels open.

Thanks again, -George

解决方案

As the build log says these two symbols are missing:

AudioServicesCreateSystemSoundID and AudioServicesPlaySystemSound

The simple solution is that it looks like you need to add the "AudioToolbox" framework to your project.

这篇关于函数“...”的隐式声明在C99上无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆