0

https://stackoverflow.com/questions/43423803/document-classification-tool-in-c-compilation-error/43432470#43432470

在上面的链接中 - 添加 -fnested_functions 后出现 3 个错误

gcc -c ./rainbow.c -fnested-functions process_wv.c test_file.c test_hdb_file.c

(3 个文件 process_wv、test_file、test_hdb_file 已从 rainbow.c 中删除,现在作为单独的 .c 文件添加到目录中)

输出:-

./bow/libbow.h:1345:8: note: forward declaration of 'struct argp_child'
struct argp_child;              /* forward declare this type */
       ^
./rainbow.c:655:5: error: function definition is not allowed here
    {
    ^
./rainbow.c:663:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
#endif VPC_ONLY
       ^
       //
./rainbow.c:734:3: warning: implicit declaration of function 'do_indexing' is invalid in C99
      [-Wimplicit-function-declaration]
  do_indexing ();
  ^
./rainbow.c:1175:49: warning: passing 'int *' to parameter of type 'socklen_t *' (aka 'unsigned int *') converts between
      pointers to integer types with different sign [-Wpointer-sign]
  newsockfd = accept(rainbow_sockfd, &cli_addr, &clilen);
                                                ^~~~~~~
/usr/include/sys/socket.h:681:69: note: passing argument to parameter here
int     accept(int, struct sockaddr * __restrict, socklen_t * __restrict)
                                                                        ^
./rainbow.c:1586:30: error: use of undeclared identifier 'test_file'
        bow_map_filenames_from_dir (test_file.c, 0, dir, "");


                             ^

PS为什么test_file.c在rainbow.c中无法识别(docnames.c中的bow_map_filenames_from_dir),即使它们位于同一个bow-20020213文件夹中(所有人的权限都是755)

问候

4

1 回答 1

0

以此..为起点:

./bow/libbow.h:1345:8: note: forward declaration of 'struct argp_child'
struct argp_child;              /* forward declare this type */

链接代码的一个主要问题是不包括该特定头文件所需的所有头文件(在任何特定头文件中)。

顺便说一句:“struct argp_child”在 ./argp/argp.h 头文件中定义。

我做了以下事情:

通过 .zip 工具下载所有文件

在我的 ubuntu linux 计算机上将 .zip 文件扩展为 ~/src_bow

cd ~/src_bow
./configure

编辑生成的“Makefile”以定义宏:

CFLAGS = -g -O -Wall -Wextra -std=gnu11 -Wimplicit

然后输入:

make -f Makefile

结果是数百个警告、注释和错误

大多数编译器输出消息都与语法、不完整的结构定义、忽略的修饰符和转换有关。但是,还暴露了许多其他问题。

在解决了几百个问题后,我停止了。

要回答您的问题,您遇到的问题的根源与未包含在其他头文件中的相应头文件有关,这些头文件需要头文件中未包含在每个头文件中的信息。

于 2017-04-18T16:23:37.130 回答