Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build error in sphfd_SWR_NLL.c file #37

Open
fontiela opened this issue Oct 18, 2023 · 3 comments
Open

build error in sphfd_SWR_NLL.c file #37

fontiela opened this issue Oct 18, 2023 · 3 comments

Comments

@fontiela
Copy link

When I compile NLL I get several errors related to the sphfd_SWR_NLL.c file

[ 85%] Building C object CMakeFiles/sphfd_SWR_NLL.dir/sphfd_SWR_NLL.c.o
/Users/joaofontiela/geophysics/NonLinLoc/src/sphfd_SWR_NLL.c:700:29: error: call to undeclared function 'gp_add_entry'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        if (name[0] == '-') gp_add_entry("SWITCH", &name[1]);
                            ^
/Users/joaofontiela/geophysics/NonLinLoc/src/sphfd_SWR_NLL.c:703:13: error: call to undeclared function 'gp_do_par_file'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
            gp_do_par_file(value, 1);
            ^
/Users/joaofontiela/geophysics/NonLinLoc/src/sphfd_SWR_NLL.c:715:9: error: call to undeclared function 'getpar'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    if (GETPAR("STOP", "s", value)) addflags |= STOP;
        ^
/Users/joaofontiela/geophysics/NonLinLoc/src/sphfd_SWR_NLL.c:597:16: note: expanded from macro 'GETPAR'
#define GETPAR getpar
               ^
/Users/joaofontiela/geophysics/NonLinLoc/src/sphfd_SWR_NLL.c:715:9: note: did you mean 'setpar'?
/Users/joaofontiela/geophysics/NonLinLoc/src/sphfd_SWR_NLL.c:597:16: note: expanded from macro 'GETPAR'
#define GETPAR getpar
               ^
/Users/joaofontiela/geophysics/NonLinLoc/src/sphfd_SWR_NLL.c:647:1: note: 'setpar' declared here
setpar(ac, av) /* set up arglist & process INPUT command */
^
/Users/joaofontiela/geophysics/NonLinLoc/src/sphfd_SWR_NLL.c:759:9: error: call to undeclared function 'gp_getpar_err'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        gp_getpar_err("setpar", "cannot allocate memory");
        ^
/Users/joaofontiela/geophysics/NonLinLoc/src/sphfd_SWR_NLL.c:763:19: error: call to undeclared function 'gp_compute_hash'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    alptr->hash = gp_compute_hash(name);
                  ^
/Users/joaofontiela/geophysics/NonLinLoc/src/sphfd_SWR_NLL.c:842:16: error: call to undeclared function 'getpar'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    if ((cnt = GETPAR(name, type, val)) > 0) return (cnt);
               ^
/Users/joaofontiela/geophysics/NonLinLoc/src/sphfd_SWR_NLL.c:597:16: note: expanded from macro 'GETPAR'
#define GETPAR getpar
               ^
/Users/joaofontiela/geophysics/NonLinLoc/src/sphfd_SWR_NLL.c:875:5: error: call to undeclared function 'gp_getpar_err'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    gp_getpar_err("mstpar", "must specify value for '%s', expecting %s",
    ^
/Users/joaofontiela/geophysics/NonLinLoc/src/sphfd_SWR_NLL.c:898:9: error: call to undeclared function 'gp_getpar_err'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        gp_getpar_err("getpar", "called after endpar");
        ^
/Users/joaofontiela/geophysics/NonLinLoc/src/sphfd_SWR_NLL.c:913:9: error: call to undeclared function 'gp_compute_hash'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    h = gp_compute_hash(name);
        ^
/Users/joaofontiela/geophysics/NonLinLoc/src/sphfd_SWR_NLL.c:942:25: error: call to undeclared function 'gp_getvector'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
                found = gp_getvector(str, type, val);
                        ^
/Users/joaofontiela/geophysics/NonLinLoc/src/sphfd_SWR_NLL.c:1055:9: error: call to undeclared function 'gp_getpar_err'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        gp_getpar_err("setpar", "%d (too many) recursive par file", level);
        ^
/Users/joaofontiela/geophysics/NonLinLoc/src/sphfd_SWR_NLL.c:1568:5: error: call to undeclared function 'read'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    read(vfint, &headin, 232);
    ^
/Users/joaofontiela/geophysics/NonLinLoc/src/sphfd_SWR_NLL.c:1568:5: note: did you mean 'fread'?
/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/usr/include/stdio.h:150:9: note: 'fread' declared here
size_t   fread(void * __restrict __ptr, size_t __size, size_t __nitems, FILE * __restrict __stream);
         ^
/Users/joaofontiela/geophysics/NonLinLoc/src/sphfd_SWR_NLL.c:1617:9: error: call to undeclared function 'close'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        close(vfint);
        ^
/Users/joaofontiela/geophysics/NonLinLoc/src/sphfd_SWR_NLL.c:6654:5: error: call to undeclared function 'writeNLLtimeGrid'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    writeNLLtimeGrid(&headout, timefile, time0);
    ^
/Users/joaofontiela/geophysics/NonLinLoc/src/sphfd_SWR_NLL.c:6657:5: error: call to undeclared function 'writeNLLmodelGrid'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    writeNLLmodelGrid(&headout, timefile, slow0);
    ^
15 errors generated.
make[2]: *** [CMakeFiles/sphfd_SWR_NLL.dir/sphfd_SWR_NLL.c.o] Error 1
make[1]: *** [CMakeFiles/sphfd_SWR_NLL.dir/all] Error 2
make: *** [all] Error 2

I tried to compile on macOS 14.0 with M1 and M2.

@alomax
Copy link
Collaborator

alomax commented Nov 14, 2023

Hello,

I am not sure I ever replied to this issue, my apologies.

The functions are declared later in the sphfd_SWR_NLL.c code, but apparently depending on compiler and compiler flags this gives an error. If you are not using sphfd_SWR_NLL, then the easiest might be to comment out in src/CMakeLists.txt the following lines:

add_executable(sphfd_SWR_NLL sphfd_SWR_NLL.c)
target_link_libraries(sphfd_SWR_NLL GRID_LIB_OBJS m)
target_compile_options(sphfd_SWR_NLL PRIVATE "-w")

and then recompile.
If you want to use sphfd_SWR_NLL or get this error for other NLL objects, then I would check which flag on your compiler should be set to either recognize the older C code conventions or to not give an error when they are used.

Anthony

@fontiela
Copy link
Author

Dear Anthony,

I follow your recommendations and I was able to compile.

Thank you

@claudiodsf
Copy link

Hi Anthony,

I attach here a patch which should make sphfd_SWR_NLL.c compilable. (But I didn't test the code).

sphfd_SWR_NLL.c.patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants