Thread Subject: problem indenting C #if

Subject: problem indenting C #if

From: Mathieu Mathieu

Date: 27 Jan, 2012 13:40:11

Message: 1 of 5

Hi,

I have problems with the indent funtion for C code:
Here is the indenting of Matlab:

void main(){
if (1)
printf("coucou");
else {
#if
printf("1");
printf("1");
#else
printf("2");
printf("2");
#endif
}
}

Normally, the printf should be aligned but Matlab does not manage to do it.
Is it normal?

thanks.

Subject: problem indenting C #if

From: James Tursa

Date: 27 Jan, 2012 15:51:10

Message: 2 of 5

"Mathieu Mathieu" wrote in message <jfu9fr$6r6$1@newscl01ah.mathworks.com>...
> Hi,
>
> I have problems with the indent funtion for C code:
> Here is the indenting of Matlab:
>
> void main(){

int main(void) {

> if (1)

if(1) {

> printf("coucou");
> else {
> #if

#if what?

> etc.

First I would suggest fixing your syntax.

James Tursa

Subject: problem indenting C #if

From: Mathieu Mathieu

Date: 27 Jan, 2012 16:20:11

Message: 3 of 5

"James Tursa" wrote in message <jfuh5e$4hs$1@newscl01ah.mathworks.com>...
> "Mathieu Mathieu" wrote in message <jfu9fr$6r6$1@newscl01ah.mathworks.com>...
> > Hi,
> >
> > I have problems with the indent funtion for C code:
you're right, however it does not impact the indenting problem.

M.

> > Here is the indenting of Matlab:
> >
> > void main(){
>
> int main(void) {
>
> > if (1)
>
> if(1) {
>
> > printf("coucou");
> > else {
> > #if
>
> #if what?
>
> > etc.
>
> First I would suggest fixing your syntax.
>
> James Tursa

Subject: problem indenting C #if

From: Mathieu Mathieu

Date: 1 Feb, 2012 10:24:10

Message: 4 of 5

nobody?


"Mathieu Mathieu" wrote in message <jfuirq$ahg$1@newscl01ah.mathworks.com>...
> "James Tursa" wrote in message <jfuh5e$4hs$1@newscl01ah.mathworks.com>...
> > "Mathieu Mathieu" wrote in message <jfu9fr$6r6$1@newscl01ah.mathworks.com>...
> > > Hi,
> > >
> > > I have problems with the indent funtion for C code:
> you're right, however it does not impact the indenting problem.
>
> M.
>
> > > Here is the indenting of Matlab:
> > >
> > > void main(){
> >
> > int main(void) {
> >
> > > if (1)
> >
> > if(1) {
> >
> > > printf("coucou");
> > > else {
> > > #if
> >
> > #if what?
> >
> > > etc.
> >
> > First I would suggest fixing your syntax.
> >
> > James Tursa

Subject: problem indenting C #if

From: Philip Borghesani

Date: 1 Feb, 2012 15:51:45

Message: 5 of 5

On 1/27/2012 8:40 AM, Mathieu Mathieu wrote:
> Hi,
>
> I have problems with the indent funtion for C code:
> Here is the indenting of Matlab:
>
> void main(){
> if (1)
> printf("coucou");
> else {
> #if
> printf("1");
> printf("1");
> #else
> printf("2");
> printf("2");
> #endif
> }
> }
>
> Normally, the printf should be aligned but Matlab does not manage to do it.
> Is it normal?
>
> thanks.

Apparently the MATLAB editor expects preprocessor statements to never be
indented as was required in pre ANSI c and is still a common convention.
  If it bothers you create a bug report.

Phil

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
indenting Mathieu Mathieu 27 Jan, 2012 08:44:11
rssFeed for this Thread

Contact us at files@mathworks.com