開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
Xoce 6.1.1
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
我只是複製課本source code 到我工作資料夾下 編譯就無法成功了
出現
Semantic issue
Control may reach end of non-void function
錯誤結果(Wrong Output):
Semantic issue
Control may reach end of non-void function
程式碼(Code):(請善用置底文網頁, 記得排版)
float sampst(float value, int variable)
{
/* Initialize, update, or report statistics on discrete-time processes:
sum/average, max (default -1E30), min (default 1E30), number of observations
for sampst variable "variable", where "variable":
= 0 initializes accumulators
> 0 updates sum, count, min, and max accumulators with new observation
< 0 reports stats on variable "variable" and returns them in transfer:
[1] = average of observations
[2] = number of observations
[3] = maximum of observations
[4] = minimum of observations */
static int ivar, num_observations[SVAR_SIZE];
static float max[SVAR_SIZE], min[SVAR_SIZE], sum[SVAR_SIZE];
/* If the variable value is improper, stop the simulation. */
if(!(variable >= -MAX_SVAR) && (variable <= MAX_SVAR)) {
printf("\n%d is an improper value for a sampst variable at time %f\n",
variable, sim_time);
exit(1);
}
/* Execute the desired option. */
if(variable > 0) { /* Update. */
sum[variable] += value;
if(value > max[variable]) max[variable] = value;
if(value < min[variable]) min[variable] = value;
num_observations[variable]++;
return 0.0;
}
if(variable < 0) { /* Report summary statistics in transfer. */
ivar = -variable;
transfer[2] = (float) num_observations[ivar];
transfer[3] = max[ivar];
transfer[4] = min[ivar];
if(num_observations[ivar] == 0)
transfer[1] = 0.0;
else
transfer[1] = sum[ivar] / transfer[2];
return transfer[1];
}
/* Initialize the accumulators. */
for(ivar=1; ivar <= MAX_SVAR; ++ivar) {
sum[ivar] = 0.0;
max[ivar] = -INFINITY;
min[ivar] = INFINITY;
num_observations[ivar] = 0;
}
}
補充說明(Supplement):
完整程式碼
simlib.c
http://ideone.com/vthy9H
這是寫好的一個simlib我是要call這個simlib一直失敗
google了一下還是不太知道怎麼解決 想說上來問版上大大這問題要怎解決
以下是完整source code
jobshop.c
http://ideone.com/PN1Pkr
simlib.h
http://ideone.com/X1PkWt
simlibdefs.h
http://ideone.com/z93OJK
jobshop.in (input file)
http://ideone.com/To0qDS