Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Mathlink problem with lists of reals

  • To:
  • Subject: [mg11161] Mathlink problem with lists of reals
  • From: Dave Grosvenor <>
  • Date: Mon, 23 Feb 1998 21:41:21 -0500
  • Organization: Hewlett Packard Laboratories, Bristol, UK


Has anyone else had a problem passing a list of Reals from mathematica
to a c program?

Or am I making a real simple mistake?

I would be grateful for examples which  do something similar.

  Dave Grosvenor

In detail

I have got mathlink to pass lists of reals from c to mathematica. But
now I want to   write the reals to a specified file.  This is so simple
I cannot beleive it is not working.

I define the following template 

:Function: writesample
:Pattern: WriteSample[filename_String, ns_RealList]
:Arguments: {filename, ns}
:ArgumentTypes: {String, RealList}
:ReturnType: Integer

This is called as follows:-


evaluating to 

The call never reaches my c function code, which is defined as follows:-

int main(int argc,char* argv[])
int result;

result = MLMain(argc,argv);

return result;

int writesample(char* filename,double px[],long nx) {
FILE* outp = fopen(filename,"wb");
long i;

for (i=0;i<nx;i++){


I have put in assert(1!=1) at various points in the writesampletm.c file
which was generated from the template, and it seems to fail much

  • Prev by Date: RE: Q:ReadList is reading spaces with numbers - what do I do?
  • Next by Date: Compiling
  • Prev by thread: dummy indices / variables (was my own sum)
  • Next by thread: Re: Mathlink problem with lists of reals