As you know you can convert your C++ code to C by replacing the classes by structures and member functions to normal functions that accept a pointer to the proper structure.
A very good example is windows API and MFC
Unfortunately it seems that Impulse has a very little support for structure as it is stated in the help file.
Do you plane to increase the support for structures or not?
Thanks
Dani.K (MEMS)
C++ to C by structure
Started by MEMS, Sep 07 2008 06:30 AM
2 replies to this topic
#1
Posted 07 September 2008 - 06:30 AM
#2
Posted 10 September 2008 - 05:57 PM
Impulse C uses this kind of object-oriented function in its I/O library (streams, shared memories, etc.). However, these are special cases recognized by the hardware compiler.
Improved support for structures is part of the long-term development plan, but won't be available in the immediate future. What features are you most interested in? The ability to pass structs through streams?
In the meantime, there are workarounds for converting C++ code. One method is to use macros associated with a "class" to marshal/unmarshal struct-based data in and out of streams, or to replace function calls with inline code accessing structures. Function calls in hardware processes ("hardware primitives") are supported already, so some method calls can be replaced with modified function calls that take as parameters only the object state data they need.
Ralph
Improved support for structures is part of the long-term development plan, but won't be available in the immediate future. What features are you most interested in? The ability to pass structs through streams?
In the meantime, there are workarounds for converting C++ code. One method is to use macros associated with a "class" to marshal/unmarshal struct-based data in and out of streams, or to replace function calls with inline code accessing structures. Function calls in hardware processes ("hardware primitives") are supported already, so some method calls can be replaced with modified function calls that take as parameters only the object state data they need.
Ralph
Ralph Bodenner
Impulse Accelerated Technologies, Inc.
Impulse Accelerated Technologies, Inc.
#3
Posted 15 September 2008 - 04:39 AM
For example consider you want to connect to differentiators together :
struct Diff
{
double Input;
double preInput;
double output;
Diff * NextElement; // this not support in Impulse
};
void ComputDiff(Diff * Element)
{
// some code
//
}
void SendResult(Diff* Element)
{// give the output to the next diffrentiator.
Element->NextElement->Input= Element->output ;
}
But Impulse dose not support pointer to other structures .
Any solution?
struct Diff
{
double Input;
double preInput;
double output;
Diff * NextElement; // this not support in Impulse
};
void ComputDiff(Diff * Element)
{
// some code
//
}
void SendResult(Diff* Element)
{// give the output to the next diffrentiator.
Element->NextElement->Input= Element->output ;
}
But Impulse dose not support pointer to other structures .
Any solution?
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












