gcc -E -dM - < /dev/nullThe -E option runs only the C preprocessor and stops. The input file is empty (/dev/null), and the -dM option generates a list of the #define directives. Numbers in the results can be in decimal or hex, and it is not always clear which is being used (e.g., does 1.17549435082228750797e-38F have a 2-digit decimal or 3-digit hex exponent?). The output varies from platform to platform, but should give a complete list of default defines. With gcc version 7.3.0, there are 347 values #defined this way.
gcc -M whatsincluded.c whatsincluded.o: whatsincluded.c /usr/include/stdc-predef.h \ /usr/include/time.h /usr/include/features.h \ /usr/include/x86_64-linux-gnu/sys/cdefs.h \ /usr/include/x86_64-linux-gnu/bits/wordsize.h \ /usr/include/x86_64-linux-gnu/bits/long-double.h \ /usr/include/x86_64-linux-gnu/gnu/stubs.h \ /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h \ /usr/include/x86_64-linux-gnu/bits/time.h \ /usr/include/x86_64-linux-gnu/bits/types.h \ /usr/include/x86_64-linux-gnu/bits/typesizes.h \ /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \ /usr/include/x86_64-linux-gnu/bits/types/time_t.h \ /usr/include/x86_64-linux-gnu/bits/types/struct_tm.h \ /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \ /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \ /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \ /usr/include/x86_64-linux-gnu/bits/types/struct_itimerspec.h \ /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \ /usr/include/x86_64-linux-gnu/bits/types/__locale_t.hOf course, edit the file whatsincluded.c to test other or additional include files.
strings diff.oThis extracts whatever can be interpreted as a printable string in the binary object file diff.o. A more useful tool is nm command, which will print which symbols are defined and which symbols are used in the file. To find which are defined in a file,
nm diff.o | grep -w TThe grep command looks for "T" as a word; "T" indicates that the symbol is defined in the file on which nm is run. (Actually, it means "The symbol is in the text (code) section" of the file). The letter "U" means that the file uses but does not define the corresponding name. In that case, some other file (object or library) must be linked in to provide the definition of the name. nm is particularly useful for library (.so) files, which can have many functions defined and you need to track down which .so file defines the function you need.
When mixing C and Fortran codes, most compilers append an underscore to names to avoid issues from Fortran's case insensitivity, and using nm and strings will help you find where an underscore is needed in calling Fortran from C or vice-versa. So if your diff.c function actually defines diff_, then the code calling it may also need to invoke diff_(), not diff().