0

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

In above link- I get 3 errors after adding -fnested_functions as

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

(The 3 files process_wv, test_file, test_hdb_file are removed from rainbow.c and added as seperate .c files to the directory now)

Output:-

./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, "");


                             ^

P.S Why is test_file.c unidentified (bow_map_filenames_from_dir in docnames.c) in rainbow.c even though they are inside the same bow-20020213 folder (Permissions are 755 for all)

Regards

Mrinmay
  • 41
  • 7

1 Answers1

0

taking this .. as a starting point:

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

The linked code has a major problem in not including all the header files (in any specific header file) that that specific header file needs.

BTW: the 'struct argp_child' is defined in the ./argp/argp.h header file.

I did the following:

downloaded all the files via the .zip facility

expanded the .zip file to ~/src_bow on my ubuntu linux computer

cd ~/src_bow
./configure

edited the resulting 'Makefile' to define the macro:

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

then entered:

make -f Makefile

The result was hundreds of warnings, notes and errors

Most of the compiler output messages were about syntax, incomplete struct definitions, ignored modifiers and conversions However, there were many many other problems exposed.

After fixing a couple of hundred of the problems I stopped.

To answer your question, the root of the problems you are having has to do with the appropriate header files not being included in other header files that need the information in the header files that are not being included in each header file.

user3629249
  • 16,402
  • 1
  • 16
  • 17