"Eli Zaretskii" <e...@gnu.org> wrote:

Well, the tests in the test suite that test this feature did work for
me at some point, so you may wish first to verify they do for you, and
then compare your extension with the ones used by the test suite, to
see what's different.

Well this is just silly. I've added tracing code a lot of places (enabled
by option --trace) . I do see my mk_test_gmk_setup() gets called, but not the new function added by gmk_add_function().
gmk_add_function() calls define_new_function(), but therein I see a:
 ent->fptr.alloc_func_ptr = func;

What about setting:
 ent->fptr.func_ptr = func;

too? How else is the new function supposed to be called? I don't understand
this contorted logic. Isn't a new function supposed to extend (and possibly
modify) the 'function_table' used from expand_builtin_function()? Thus possibly replacing a built-in? Please somebody clarify.

For reference, here is my complete mk_test.c:

 #include <stdlib.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
 #include "gnumake.h"

 #define EXPORT __declspec(dllexport)

 EXPORT int plugin_is_GPL_compatible;

 static char *hello_world (const char *func_name, int argc, char **argv)
 {
   char *buf = gmk_alloc(1000), *p = buf;
   int  i;

   fprintf (stdout, "hello_world() called: %s\n", func_name);

   for (i = 0; i < argc; i++)
   {
     fprintf (stdout, "argv[%d]: %s\n", i, argv[i]);
     p += sprintf (p, "%s+", argv[i]);
   }
   return (buf);
 }

 EXPORT int mk_test_gmk_setup (const gmk_floc *flocp)
 {
   gmk_add_function ("hello_world", hello_world, 0, 255, 0);
   fprintf (stdout, "\"%s()\" called from %s (%lu)\n",
            __FUNCTION__, flocp->filenm, flocp->lineno);
   return (1);
 }

--gv



_______________________________________________
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make

Reply via email to