* Problem compiling .cpp file
@ 2002-11-05 16:41 jblazi
0 siblings, 0 replies; 3+ messages in thread
From: jblazi @ 2002-11-05 16:41 UTC (permalink / raw)
I have the following file:
#include <guile/gh.h>
#include <stdio.h>
SCM test_function(SCM n)
{
printf("Die Zahl ist %d\n",SCM_INUM(n));
return SCM_EOL;
}
void register_procs(void)
{
gh_new_procedure("test_function",test_function,1,0,0);
}
void inner_main(int argc, char **argv)
{
register_procs();
gh_repl(argc, argv);
}
main(int argc,char *argv[])
{
gh_enter(argc, argv, inner_main);
return(0); /* never reached */
}
I am compiling the file with
gcc -Iusr/include test2.c -o test2 -lguile -lm
This more or less works (it does not work really as I get error messages when
I call the function test_function from Guile, but at least after the first
call the text is displayed.)
But when I try to compile the same file as a .cpp file, it does not work:
Administrator@PAPUA-8ZRG78JQB ~/c-programme
$ mv test2.c test2.cpp
Administrator@PAPUA-8ZRG78JQB ~/c-programme
$ gcc -Iusr/include test2.cpp -o test2 -lguile -lm
test2.cpp: In function `void register_procs()':
test2.cpp:12: invalid conversion from `
scm_unused_struct*(*)(scm_unused_struct*)' to `scm_unused_struct*(*)()'
*/
I use the latest Cygwin (with gcc 3.2) on Win2K.
Can anybody help me?
TIA,
--
Janos Blazi
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 3+ messages in thread
* Problem compiling .cpp file
@ 2002-11-05 16:47 jblazi
2002-11-05 21:07 ` Marius Vollmer
0 siblings, 1 reply; 3+ messages in thread
From: jblazi @ 2002-11-05 16:47 UTC (permalink / raw)
I have the following file:
#include <guile/gh.h>
#include <stdio.h>
SCM test_function(SCM n)
{
printf("Die Zahl ist %d\n",SCM_INUM(n));
return SCM_EOL;
}
void register_procs(void)
{
gh_new_procedure("test_function",test_function,1,0,0);
}
void inner_main(int argc, char **argv)
{
register_procs();
gh_repl(argc, argv);
}
main(int argc,char *argv[])
{
gh_enter(argc, argv, inner_main);
return(0); /* never reached */
}
I am compiling the file with
gcc -Iusr/include test2.c -o test2 -lguile -lm
This more or less works (it does not work really as I get error messages when
I call the function test_function from Guile, but at least after the first
call the text is displayed.)
But when I try to compile the same file as a .cpp file, it does not work:
Administrator@PAPUA-8ZRG78JQB ~/c-programme
$ mv test2.c test2.cpp
Administrator@PAPUA-8ZRG78JQB ~/c-programme
$ gcc -Iusr/include test2.cpp -o test2 -lguile -lm
test2.cpp: In function `void register_procs()':
test2.cpp:12: invalid conversion from `
scm_unused_struct*(*)(scm_unused_struct*)' to `scm_unused_struct*(*)()'
*/
I use the latest Cygwin (with gcc 3.2) on Win2K.
Can anybody help me?
TIA,
--
Janos Blazi
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Problem compiling .cpp file
2002-11-05 16:47 Problem compiling .cpp file jblazi
@ 2002-11-05 21:07 ` Marius Vollmer
0 siblings, 0 replies; 3+ messages in thread
From: Marius Vollmer @ 2002-11-05 21:07 UTC (permalink / raw)
Cc: bug-guile
jblazi <jblazi@gmx.de> writes:
> test2.cpp: In function `void register_procs()':
> test2.cpp:12: invalid conversion from `
> scm_unused_struct*(*)(scm_unused_struct*)' to `scm_unused_struct*(*)()'
> */
You need to use an explicit cast in C++:
gh_new_procedure("test_function",(SCM (*)())test_function,1,0,0);
You also should not use SCM_INUM. It does no error checking and works
only with 'fixnums' (small integers). Use scm_num2int instead:
SCM test_function(SCM n)
{
printf ("Die Zahl ist %d\n", scm_num2int (n, 1, "test_function"));
return SCM_EOL;
}
--
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-11-05 21:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-05 16:47 Problem compiling .cpp file jblazi
2002-11-05 21:07 ` Marius Vollmer
-- strict thread matches above, loose matches on Subject: below --
2002-11-05 16:41 jblazi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).