Matlab compiler c language error

8 ビュー (過去 30 日間)
ning zhang
ning zhang 2017 年 12 月 6 日
コメント済み: Jan 2017 年 12 月 17 日
1.Matlab compiles C language error, but the code should be correct, other people can run successful, report wrong on my computer.Enter this sentence "mex -v -setup",get
2.but when I compile c, I make a mistake.
  4 件のコメント
ning zhang
ning zhang 2017 年 12 月 6 日

Yes, I used https://github.com/xieyaxiongfly/Atheros-CSI-Tool-UserSpace-APP.

ning zhang
ning zhang 2017 年 12 月 6 日
Yes, I used it. Could you help me? Thank you .

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

採用された回答

Jan
Jan 2017 年 12 月 6 日
編集済み: Jan 2017 年 12 月 6 日
read_csi.c line 65:
local_h = mxGetData(prhs[0]);
This does not match to the message "missing ; before type". Therefore there must be another problem. I see this in line 78:
int size[] = {nr, nc, num_tones};
In strict C (to be exact: C89) all variables must be declared before the first command in a [function - wrong, better:] scope block (thanks Walter). But declaring variables inside the code is allowed in C++. So try to rename the file from .c to .cpp and see, if the compilation works then.
If this solves the problem: Let me mention that you would find several corresponding discussions, if you ask an internet search engine for "Matlab Mex missing ; before type".
  10 件のコメント
Walter Roberson
Walter Roberson 2017 年 12 月 15 日
編集済み: Walter Roberson 2017 年 12 月 15 日
When you run code and get the expected answer for a single test, that does not mean that the code is right: it can just mean that you did not happen to encounter the conditions under which the code was wrong.
Also, in C, there are a number of constructs whose meaning is not completely specified by the standards, so the behaviour can depend on the compiler being used and upon the compiler settings, so you can encounter situations in which the behaviour of code changes after a seemingly unrelated compiler or operating system or processor change.
Jan
Jan 2017 年 12 月 17 日
@N Z: There is no reason for being sorry. Asking question is welcome here. I only want to support, that you get the required results in a reliable and trustworthy way. C code is magnitudes more fragile than Matlab code. The missing checks of array limits, the power to use pointers to access everything and low level access to the memory offers a high computational speed and the power to drill a hole in your computer in nano seconds. Code can run "successfully" thousands of times by accident, and fail tremendously in another run.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCOM Component Integration についてさらに検索

Community Treasure Hunt

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

Start Hunting!