How to know where an identifier was defined before

Pages: 12
Found it: https://github.com/ryanolson/ddi
A suggestion, sm9: learn how to use your computer. You should not be asking other people to look for macro definitions for you.

DDI_GETACC is indeed defined in include/ddi.h as 6. To be honest, I'm not sure what to do at this point. I don't know what the original developer intended by defining some functions to possibly have the same names as some symbolic constants. You could try defining _UNDERSCORES to be something other 0, but I have no idea if that will have some unintended effect when trying to link everything together.
sm9 wrote:
Now I want to know where exacly F77_GetAcc was defined before, and whether putting #undef is going to harm the program in any way.


The code you would like to undef is
1
2
3
4
5
void F77_GetAcc(int_f77 *handle, int_f77 *ilo, int_f77 *ihi,
                                 int_f77 *jlo, int_f77 *jhi, void *buff) {
      
     DDI_GetAcc(*handle,*ilo-1,*ihi-1,*jlo-1,*jhi-1,buff);
   }


The code that the macro points to is
1
2
3
4
5
   void 6(int_f77 *handle, int_f77 *ilo, int_f77 *ihi,
                                 int_f77 *jlo, int_f77 *jhi, void *buff) {
      
     DDI_GetAcc(*handle,*ilo-1,*ihi-1,*jlo-1,*jhi-1,buff);
   }


They do exactly the same thing (which, I would guess, is to cater for the fact that Fortran arrays start from 1 (by default) and C/C++ arrays start from 0 (always)). A worse problem here would be that the ij storage order in 2-d arrays is likely to be different.

So you can safely delete the routine that you have considered putting undef before.

My guess is that somebody put this variant routine there whilst they were debugging and forgot to remove it afterward.

If that's the only thing stopping this code compiling then you are lucky.
Last edited on
@helios Thanks! I am not a programmer, I am a chemist, so these things are mostly unknown to me.

@lastchance Thanks. I will try that and hopefully the program works.
Topic archived. No new replies allowed.
Pages: 12