Message Boards Message Boards

Finding the mdefs.h C header file to utilize Cform function output

Posted 6 months ago

I am using Mathematica to do proof of concept work with some computational physics simulations. The goal being to scale up these simulations in C. The Cform[] output for my Mathematica Cells is very valuable, however, when looking online for how to use the the need macros I find that I need the mdefs.h file library to link my code to. I have not been able to located it? Where can I search or do I need to download a developer kit seperatly? I am using a Mac with Mathematica 13.2.

POSTED BY: Ed di Girolamo
4 Replies

Great, That command worked. I have an additional question. In using CForm[] there are macros that are used not in the mdefs.h file. Nor do the other .h files in the same directory seem to hold them (I could be wrong, but no success with a grep search on the contents of the folder for macros labelled "List or InterpolatingFunction". Where would I find more of the appropriate header files?

POSTED BY: Ed di Girolamo

Do you have an example of such a macro? Keep in mind that the scope of CForm is very limited, it only understands a tiny subset of the language and in most cases its output will not actually be compilable C code. See also the C code generation tutorial in the documentation for what is feasible in terms of generated code (interpolating functions are definitely not).

POSTED BY: Ilian Gachevski

I have been attempting to try various simple functions but the C code generation tutorial will help me sort it out for my next actual project. Thank you for that resource and link!

POSTED BY: Ed di Girolamo

Try evaluating FileNames["mdefs.h", $InstallationDirectory, Infinity]

POSTED BY: Ilian Gachevski
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract