0
未定义的符号正在此错误对我的代码:用于建筑
Undefined symbols for architecture x86_64:
"_spendDollars", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
已经检查了代码,但找不到错误。这是:
#import <Foundation/Foundation.h>
typedef struct {
float exchangeRate;
double budget;
//double euroTransaction;
double exchangeTransaction;
} budget;
//budget vacationBudget;
budget vacationBudgetEurope;
budget vacationBudgetEngland;
//void spendDollars (double dollars);
//void chargeEuros (double euros);
void spendDollars(budget* theBudget, double dollars);
void chargeForeignCurrency(budget* theBudget, double foreignCurrency);
int main(int argc, const char * argv[])
{
//budget vacationBudget;
//vacationBudget.exchangeRate = 1.2500;
vacationBudgetEurope.budget = 1000;
//vacationBudget.budget = 1000.00;
vacationBudgetEurope.budget = 1000.00;
//double numberDollars = 100;
double numberDollarsInEuroland = 100;
double numberEuros = 100;
vacationBudgetEngland.exchangeRate = 1.5000;
vacationBudgetEngland.budget = 2000.00;
double numberDollarsInPoundland = 100;
double numberPounds = 100;
//vacationBudget.budget -= 100.00;
//spendDollars(numberDollars);
spendDollars(&vacationBudgetEurope, numberDollarsInEuroland);
//NSLog(@"Converting %.2f US dollars into euros leaves $%.2f dollars", numberDollars, vacationBudget.budget);
NSLog(@"Converting %.2f US dollars into euros leaves $%.2f", numberDollarsInEuroland, vacationBudgetEurope.budget);
//chargeEuros(numberEuros);
chargeForeignCurrency(&vacationBudgetEurope, numberEuros);
//NSLog(@"Charging %.2f euros leaves $%.2f", numberEuros, vacationBudget.budget);
NSLog(@"Charging %.2f euros leaves $%.2f", numberEuros, vacationBudgetEurope.budget);
spendDollars(&vacationBudgetEngland, numberDollarsInPoundland);
NSLog(@"Converting %.2f US dollars into pounds leaves $%.2f", numberDollarsInPoundland, vacationBudgetEngland.budget);
chargeForeignCurrency(&vacationBudgetEngland, numberPounds);
NSLog(@"Charging %.2f pounds leaves $%.2f", numberPounds, vacationBudgetEngland.budget);
return 0;
}
//void spendDollars (double dollars) {
// vacationBudget.budget -= dollars;
//}
void chargeForeignCurrency (budget* theBudget, double foreignCurrency) {
theBudget -> exchangeTransaction = foreignCurrency*theBudget -> exchangeRate;
theBudget ->budget -= theBudget -> exchangeTransaction;
}
'void spendDollars(budget *,double)'的定义在哪里? – 2012-03-22 23:50:08