C Interface example



Hi.

I'm having a bit of trouble getting my head around calling C code
in Ada. I'll spare you my failed attempts, basically I have this code:

(vector.h)

#ifndef VECTOR_H
#define VECTOR_H

float *vec_addNf(float *, float *, unsigned int);

#endif

(vec_add.c)

#include "vector.h"

float *vec_add(float *va, float *vb, unsigned int ne)
{
unsigned int ind;
for (ind = 0; ind < ne; ++ind)
va[ind] += vb[ind];
return va;
}

Now what would be the most simple and portable way to write
a vector,ads and vector.adb file? (Specification and body, in case
those are compiler-specific filenames, I'm not intimate with the
Ada language spec yet!). I just don't have a good enough
understanding of the language to see how it all fits together
yet and I usually learn by example.

MC

.



Relevant Pages

  • Re: C Interface example
    ... I'm having a bit of trouble getting my head around calling C code ... in Ada. ... I'll spare you my failed attempts, ...
    (comp.lang.ada)
  • Re: C Interface example
    ... Ada language spec yet!). ... for i in va'Range loop ...
    (comp.lang.ada)
  • Re: Certified C compilers for safety-critical embedded systems
    ... >> Ada functions are simply a procedure with a different calling syntax. ... I'm not talking about the compiler writer. ... > syntax) between functional and procedural programming languages. ...
    (comp.lang.ada)
  • Re: Error-names.
    ... an exception you never thought about when designing the component. ... >> If you are writing a bridge that is controlled by C executable accessing an ada ... All exceptions are passed to the calling ... The advantage of this programming lifestyle which I learned from OLE(windows ...
    (comp.lang.ada)
  • Re: Blocking syscalls in Tasks
    ... Except for DOS in todays OS all Ada partitions are executed by native OS ... Only the calling Ada task aka thread is blocked, ... parameter which can be used to unblock the call and task at a set time ...
    (comp.lang.ada)