Ask Your Question
1

Calling a C function with printf from sage

asked 9 years ago

kroovy gravatar image

Hi,

I'm trying to run the first example in doc.sagemath.org/html/en/thematic_tutorials/cython_interface.html on SageMathCloud. After creating the necessary hello.c and hello_sage.pyx, I tried running the Cython function in a sage notebook:

%runfile hello_sage.pyx
my_bridge_function()

The problem is that I see the pyx was compiled successfully, but nothing is printed.

I would appreciate any help on how to run the example, or an alternative way to print from a C function that would be visible in the notebook. (I have a more complex C file that I'm trying to run, but it is difficult to debug it without printing)

Thanks

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 9 years ago

Harald Schilly gravatar image

The issue is, that C prints somewhere, where the sagews isn't picking it up. Maybe rewriting print such that it appends to stdout helps?

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 9 years ago

Seen: 739 times

Last updated: Feb 24 '16