Import Function is not supported

Hi,
I am converting my MATLAB code into C code using MATLAB Coder. However, this error popped out while I'm trying to convert it.
It said that the import statements below are not supported.
How am I supposed to modify the code? I need it for my project to run smoothly.
Thank you.

回答 (1 件)

David Fink
David Fink 2020 年 5 月 11 日

0 投票

import is used to bring names into scope.
Instead of:
import x.y.*
functionInXY();
use
x.y.functionInXY();
Please contact MathWorks Technical Support to formally express your interest in supporting import in a future release.

6 件のコメント

WanYu
WanYu 2020 年 5 月 11 日
編集済み: WanYu 2020 年 5 月 11 日
Hi,
Thanks for answering.
It is not working as it cannot recognise the function.
The imported files are written in Java, yet now I want to import it to my code so I can use the functions inside.
Thank you.
David Fink
David Fink 2020 年 5 月 11 日
Based on the import statements in the question, those appear to be packages, so calling them as functions will not work.
In fact, the .* syntax is not recommended in MATLAB. See the import page for details:
To remove the import-s, you will need to identify the functions and classes used in the body of decode that exist in those packages, and prepend the appropriate package name to each.
To draw a parallel to my example above, com.google.zxing.qrcode = x.y, but there may be various calls corresponding to functionInXY.
For example,
import com.google.zxing.qrcode
reader = QRCodeReader;
becomes
reader = com.google.zxing.qrcode.QRCodeReader;
WanYu
WanYu 2020 年 5 月 11 日
Hi,
I have tried the method shown, however it cannot recognised the "com" function.
David Fink
David Fink 2020 年 5 月 11 日
Doing some searching, those packages look like Java.
MATLAB Coder does not support calling Java.
MATLAB Compiler (not my area of expertise) might support calling Java from a MATLAB Compiler executable:
WanYu
WanYu 2020 年 5 月 12 日
Hi,
If I wish to call Java in my code from MATLAB Coder, it will not work?
David Fink
David Fink 2020 年 5 月 12 日
If generating a MEX file, MATLAB Coder can call into MATLAB (which can call Java) via coder.extrinsic.
If generating standalone C code, MATLAB Coder cannot call into MATLAB or Java.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeIntroduction to Installation and Licensing についてさらに検索

製品

リリース

R2019b

質問済み:

2020 年 5 月 11 日

コメント済み:

2020 年 5 月 12 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by