[Interoperability of Octave and MATLAB: conflicts in 'mxArray' definition]

Maxim Abalenkov <[email protected]>
Newsgroups gmane.comp.gnu.octave.general
Message-ID <[email protected]>
Dear all,

I have an interesting task. As part of our research project I would like to call Octave’s interpreter from a MATLAB function and autogenerate the final C++ code with help of MATLAB Coder. I have almost reached the end goal. You may follow my progress in this MATLAB Central thread: https://www.mathworks.com/matlabcentral/answers/759691-instantiate-an-instance-of-c-object-via-matlab-coder?s_tid=prof_contriblnk <https://www.mathworks.com/matlabcentral/answers/759691-instantiate-an-instance-of-c-object-via-matlab-coder?s_tid=prof_contriblnk>. Unfortunately, there is a final hurdle I need to overcome. This is the same data structure called “mxArray” used in both Octave and MATLAB. As I understand the definitions of “mxArray” are different in Octave and MATLAB. Once I try to compile the resulting MATLAB code with MATLAB Coder pulling in the Octave Interpreter definitions I receive an error due to conflicts in “mxArray”:

In file included from inter_c.cpp:15:
In file included from /Users/mabalenk/repo/git/alc/rascal/oct/inter.h:2:
In file included from /opt/local/include/octave-6.1.0/octave/interpreter.h:40:
In file included from /opt/local/include/octave-6.1.0/octave/cdef-manager.h:31:
In file included from /opt/local/include/octave-6.1.0/octave/cdef-class.h:37:
In file included from /opt/local/include/octave-6.1.0/octave/cdef-method.h:37:
In file included from /opt/local/include/octave-6.1.0/octave/cdef-object.h:36:
In file included from /opt/local/include/octave-6.1.0/octave/error.h:37:
In file included from /opt/local/include/octave-6.1.0/octave/oct-map.h:36:
In file included from /opt/local/include/octave-6.1.0/octave/Cell.h:36:
/opt/local/include/octave-6.1.0/octave/ov.h:54:7: error: definition of type 'mxArray' conflicts with typedef of the same name
class mxArray;
      ^
/Applications/MATLAB_R2020b.app/extern/include/matrix.h:157:28: note: 'mxArray' declared here
typedef struct mxArray_tag mxArray;
                           ^

Therefore, I would like to ask, is there an elegant way to resolve these definition conflicts? Maybe the conflicts can be avoided by using a certain C++ namespace? A brute force approach would be to rename “mxArray” in Octave code base into a “mtrxArray” for example. But I would like to avoid such intrusive modifications to the code. Any of your suggestions and guidance would be most welcome. I asked this question on Octave Discourse forum: https://octave.discourse.group/t/calling-octave-interpreter-using-matlab-coder/837 <https://octave.discourse.group/t/calling-octave-interpreter-using-matlab-coder/837>. But so far there were no responses. Thank you for your help and have a good day ahead!

—
Best wishes,
Maxim

Maxim Abalenkov \\ [email protected]
+44 7 486 486 505 \\ http://mabalenk.gitlab.io
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.