GCC/G++ 错误 Mac OS X Yosemite

GCC/G++ Errors Mac OS X Yosemite

几个星期以来,我一直在使用新的 Mac,它与 OS X Yosemite(版本 10.10.3)一起工作。我发现从源代码安装程序有很多麻烦,为什么我已经将编译器更改为 gcc 4.2、4.7 和 4.9。此外,我 "removed" 与 clang 的连接,但这在编译过程中仍然会产生错误。但是,在 Mac OS X 机器版本 10.7.5 上执行相同的操作可以正常工作。在那里,gcc 版本 4.2.1 是 运行.

这是一个示例错误消息,我在命令行中输入 make:

cc -O2   -c -o swat.o swat.c
In file included from swat.c:25:
./swat.h:85:35: warning: '/*' within block comment [-Wcomment]
  /*  int *maxstu_vec; NOT NEEDED /* array of length length + 1, used to hold row of scores,
                                  ^
swat.c:29:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
compare_scores(entry1, entry2)
^
swat.c:35:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
compare_z_scores(entry1, entry2)
^
swat.c:42:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
compare_E_values(entry1, entry2)
^
swat.c:49:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
main(argc,argv)
^
swat.c:75:3: warning: implicit declaration of function 'get_parameters' is invalid in C99 [-Wimplicit-function-declaration]
  get_parameters(argc, argv, "swat"); 
  ^
swat.c:85:3: warning: implicit declaration of function 'alloc_hist' is invalid in C99 [-Wimplicit-function-declaration]
  alloc_hist();
  ^
swat.c:86:10: warning: implicit declaration of function 'get_next_file_entry' is invalid in C99 [-Wimplicit-function-declaration]
  while (get_next_file_entry(qdb)) {
         ^
swat.c:95:5: warning: implicit declaration of function 'notify' is invalid in C99 [-Wimplicit-function-declaration]
    notify("Searching: ");
    ^
swat.c:98:12: warning: implicit declaration of function 'append_seq_entry' is invalid in C99 [-Wimplicit-function-declaration]
        s_entry = append_seq_entry(sdb);
                  ^
swat.c:110:2: warning: implicit declaration of function 'set_score' is invalid in C99 [-Wimplicit-function-declaration]
        set_score(s_entry, score);
        ^
swat.c:127:57: warning: implicit declaration of function 'get_seq_length' is invalid in C99 [-Wimplicit-function-declaration]
        score = parameters->align(q_profile, get_seq(s_entry), get_seq_length(s_entry), 1, 0, 0, 0, 0, 0);
                                                               ^
swat.c:146:5: warning: implicit declaration of function 'initialize_hist' is invalid in C99 [-Wimplicit-function-declaration]
    initialize_hist(); 
    ^
swat.c:155:7: warning: implicit declaration of function 'update_hist' is invalid in C99 [-Wimplicit-function-declaration]
      update_hist(score_entry, 0);
      ^
swat.c:158:5: warning: implicit declaration of function 'process_hist' is invalid in C99 [-Wimplicit-function-declaration]
    process_hist();
    ^
swat.c:172:2: warning: implicit declaration of function 'fit_log_n' is invalid in C99 [-Wimplicit-function-declaration]
        fit_log_n(q_length);
        ^
swat.c:175:4: warning: implicit declaration of function 'find_z' is invalid in C99 [-Wimplicit-function-declaration]
          find_z(score_entry);
          ^
swat.c:195:9: warning: implicit declaration of function 'reject_entry' is invalid in C99 [-Wimplicit-function-declaration]
          if (!reject_entry(score_entry)) nz++; /* assumes Smith-Waterman */
               ^
swat.c:202:7: warning: implicit declaration of function 'new_est_lambda_K' is invalid in C99 [-Wimplicit-function-declaration]
      new_est_lambda_K(q_length, score_entries, last_score_entry);
      ^
swat.c:242:24: warning: '&&' within '||' [-Wlogical-op-parentheses]
        if (parameters->use_n && score_entry >= score_entries + parameters->max_num_alignments
            ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
swat.c:242:24: note: place parentheses around the '&&' expression to silence this warning
        if (parameters->use_n && score_entry >= score_entries + parameters->max_num_alignments
                              ^
            (                                                                                 )
swat.c:243:24: warning: '&&' within '||' [-Wlogical-op-parentheses]
         || parameters->use_z && score_entry->z < parameters->z_cutoff || !score_entry->score) 
         ~~ ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
swat.c:243:24: note: place parentheses around the '&&' expression to silence this warning
         || parameters->use_z && score_entry->z < parameters->z_cutoff || !score_entry->score) 
                              ^
            (                                                         )
swat.c:256:29: warning: data argument not used by format string [-Wformat-extra-args]
               score_entry->score, score_entry->z, e_value, score_entry->E);
                                   ^
swat.c:261:2: warning: implicit declaration of function 'print_alignment' is invalid in C99 [-Wimplicit-function-declaration]
        print_alignment(q_profile);
        ^
swat.c:266:65: warning: data argument not used by format string [-Wformat-extra-args]
                get_id(seq_num), get_seq_length(seq_num), score_entry->score, score_entry->z);
                                                                              ^
swat.c:272:5: warning: implicit declaration of function 'free_profile' is invalid in C99 [-Wimplicit-function-declaration]
    free_profile(q_profile);
    ^
25 warnings generated.
cc -O2   -c -o weibull.o weibull.c
In file included from weibull.c:25:
./swat.h:85:35: warning: '/*' within block comment [-Wcomment]
  /*  int *maxstu_vec; NOT NEEDED /* array of length length + 1, used to hold row of scores,
                                  ^
weibull.c:47:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
reject_entry(score_entry)
^
weibull.c:50:32: warning: '&&' within '||' [-Wlogical-op-parentheses]
  return (!parameters->nw_flag && !score_entry->score || score_entry->length < LENGTH_CUTOFF);
          ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ ~~
weibull.c:50:32: note: place parentheses around the '&&' expression to silence this warning
  return (!parameters->nw_flag && !score_entry->score || score_entry->length < LENGTH_CUTOFF);
                               ^
          (                                          )
weibull.c:53:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
alloc_hist()
^
weibull.c:65:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
weibull.c:67:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
initialize_hist()
^
weibull.c:78:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
weibull.c:80:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
update_hist(score_entry, z_flag)
^
weibull.c:88:5: error: non-void function 'update_hist' should return a value [-Wreturn-type]
    return;
    ^
weibull.c:92:5: error: non-void function 'update_hist' should return a value [-Wreturn-type]
    return;
    ^
weibull.c:106:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
prune_hist(score_entry)
^
weibull.c:111:34: error: non-void function 'prune_hist' should return a value [-Wreturn-type]
  if (reject_entry(score_entry)) return;
                                 ^
weibull.c:127:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
process_hist()
^
weibull.c:155:5: warning: implicit declaration of function 'fatalError' is invalid in C99 [-Wimplicit-function-declaration]
    fatalError("No entries have scores exceeding -gap_init");
    ^
weibull.c:168:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
fit_log_n(q_length)
^
weibull.c:300:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
est_lambda_K(q_length) 
^
weibull.c:399:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
new_est_lambda_K(q_length, score_entries, last_score_entry) /* using non-extreme-value dist'n */
^
weibull.c:644:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
find_z(entry)
^
weibull.c:652:21: warning: implicit declaration of function 'make_log_table' is invalid in C99 [-Wimplicit-function-declaration]
    if (!log_table) make_log_table();
                    ^
weibull.c:665:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
make_log_table()
^
17 warnings and 3 errors generated.
make: *** [weibull.o] Error 1

也许你们中有人知道,问题可能是什么???

我会很高兴得到每一个答案:)

weibull.c:88:5: error: non-void function 'update_hist' should return a value [-Wreturn-type]
    return;
    ^
weibull.c:92:5: error: non-void function 'update_hist' should return a value [-Wreturn-type]
    return;
    ^

weibull.c:111:34: error: non-void function 'prune_hist' should return a value [-Wreturn-type]
  if (reject_entry(score_entry)) return;
                                 ^

必须return给定函数头中类型的值。

我找到了解决办法。正如我已经担心的那样,问题出在编译器上。 我安装了一个相对较新的版本(gcc 4.9),将此版本设置为活动版本并在 ~/.bash_profile 中添加了路径(这是最重要的一步)。此外,我采用了makefile。打开一个新终端并输入 "make" 运行没有错误。