Why do I get "illegal statement termination" compile-time errors when building a C source file with MBUILD in MATLAB Compiler 4.9 (R2008b)?

조회 수: 8 (최근 30일)
I have simple C-file and the code is provided below:
#include <stdio.h>
int main() {
printf("Hello World \n");
int a;
return 0;
}
When I try to create a standalone application from the C-file using MBUILD, I receive the following error messages:
Error T:\1-83SFP9\FORSWA~1\trial.c: 5 illegal statement termination
Error T:\1-83SFP9\FORSWA~1\trial.c: 5 skipping `int'
Error T:\1-83SFP9\FORSWA~1\trial.c: 5 undeclared identifier `a'
Warning T:\1-83SFP9\FORSWA~1\trial.c: 5 Statement has no effect
Warning T:\1-83SFP9\FORSWA~1\trial.c: 5 possible usage of a before definition

채택된 답변

MathWorks Support Team
MathWorks Support Team 2009년 6월 27일
The error occurs because in ANSI C, all variables must be declared at the beginning of a function before any other executable statements. To resolve the issue, modify the code as shown below:
#include <stdio.h>
int main() {
int a;
printf("Hello World \n");
return 0;
}

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 C Shared Library Integration에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

제품


릴리스

R2008b

Community Treasure Hunt

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

Start Hunting!

Translated by