Hi Agobin --

I've got a patch to the compiler that should get you past the immediate internal error you're running into, though I'm worried you'll slam into another problem shortly after that. (I don't have easy access to gtk, so can't easily get much further myself...)

Specifically, as I mentioned last week, our support for first-class functions (passing functions to other functions) is not ideal at present. In particular, the ability to pass function pointers to external functions as you're trying to do in the expression 'G_CALLBACK(g_print)' isn't something that will work at present. This is a(n increasingly) frequently requested feature from users making use of Chapel's extern support.

(Maybe not of interest, but the reason it doesn't work today is that when we pass functions around in Chapel, we pass around more than just a function pointer in order to support closure-style semantics; and we try to do the same for external functions even though they're not expecting our closure types).

That said, in a simple test program I was trying, I came up with a potential workaround to try. Assuming that you don't need to call g_print() directly from within Chapel, I believe that you can tell the compiler a white lie to make this work. Namely, change g_print's declaration to:

        var g_print: opaque;

which says "there's this external variable named g_print whose type I can't describe to you." This will permit the compiler to generate references to 'g_print' in the generated code without thinking that it's a function.

(If you did need to both call a function and pass it as a function pointer I think that we'd have to tell further white lies, potentially by introducing an alias to the function in a C header file).

Will you let me know whether this patch and/or workaround work for you?

Thanks,
-Brad


On Sun, 20 Mar 2016, Agobin Fobella wrote:

Hello Chapel developers,

I was compiling this project
<https://github.com/Agobin/Chapel_Tic_Tac_Toe_Game> of mine with chpl.
Chapel's compiler reported this error message
<https://github.com/Agobin/Chapel_Tic_Tac_Toe_Game/blob/master/compilerMessage.txt>
to me, indicating it had
found a bug.
The error originated from this file this file
<https://github.com/Agobin/Chapel_Tic_Tac_Toe_Game/blob/master/ttt.chpl> on
line 29.

The function g_signal_connect() in the above mentioned file is a C function
extended into chapel. It links a signal ( its second argument) from a widget
(its first argument) to a callback function (its third argument) passing
its fourth argument to the callback function(g_print).

The functions g_print (the third argument of g_signal_connect()) is an
extended
c function similar to chapel's writeln() that prints its arguments to the
terminal.

Please for your feedback as it would enhance this project's development
or give me an alternative approach of working around the error message.

 Additional information
chpl version: 1.12.0
gcc version:  5.3.1
Output of  $CHPL_HOME/util/printchplenv script
<https://github.com/Agobin/Chapel_GUI_testing/blob/master/ScriptOutput>

Thanks,
Agobin.
diff --git a/compiler/passes/resolveIntents.cpp b/compiler/passes/resolveIntents.cpp
index dd54448..e564067 100644
--- a/compiler/passes/resolveIntents.cpp
+++ b/compiler/passes/resolveIntents.cpp
@@ -41,6 +41,7 @@ static IntentTag constIntentForType(Type* t) {
              t == dtTaskID ||
              t == dtFile ||
              t == dtNil ||
+             t == dtAny ||
              t == dtStringC ||
              t == dtStringCopy ||
              t == dtCVoidPtr ||
@@ -71,6 +72,7 @@ IntentTag blankIntentForType(Type* t) {
              isUnion(t) ||
              t == dtTaskID ||
              t == dtFile ||
+             t == dtAny ||
              t == dtNil ||
              t == dtOpaque ||
              t->symbol->hasFlag(FLAG_DOMAIN) ||
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140
_______________________________________________
Chapel-bugs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-bugs

Reply via email to