Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the proper way to write a C MathLink function that returns nothing at all?

The following works, but I'm not sure if all this work is actually necessary:

The template file:

:Begin:
:Function:      fun
:Pattern:       fun[]
:Arguments:     {}
:ArgumentTypes: {}
:ReturnType:    Manual
:End:

The C code:

void fun() {
    MLPutSymbol(stdlink, "Null");
}

In short, here I set the return type to Manual and explicitly returned Null. Is this all necessary or is there a shorter way?

share|improve this question
up vote 8 down vote accepted

That's exactly what you do. You need to send something back to Mathematica, and the symbol Null is the sensible choice.

share|improve this answer
    
Hmm, and here, you were faster.. – halirutan Jan 30 '13 at 6:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.