Keil Logo

error C141: syntax error near 'unsigned'

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
danish p.
Posted
25-Oct-2006 10:13 GMT
Toolset
C51
New! error C141: syntax error near 'unsigned'

hi there, i have struct with the problem.in the multiplexing of the 7-segment display. as i complited the 7-segment display multiplexing. prog.is working properly. but when i moved to the next some advance step it give's the above msg. i think the problem is in the variable passing between function. because as i try to pass the local data to globle side

can any one explain me the passing the value's between two function. the function returning the value is in the main function
and
the function which recive's the value is out of the main function

the function which recive's the value is out of the main function is the part of the interrupt routine


the function which sending or returning the value is the part of main function

Read-Only
Author
Andy Neil
Posted
25-Oct-2006 10:27 GMT
Toolset
C51
New! It's a syntax error

"i think the problem is in the variable passing between function."

Why do you think that?

The message is a syntax error; ie, what you have written is not valid C51 syntax.

http://dictionary.cambridge.org/define.asp?key=80868&dict=CALD

http://www.keil.com/support/man/docs/c51/c51_c141.htm

This could be a simple typo - eg, missing semicolon or spelling mistake.

Note that it says "near" - this probably means that the error is somewhere before the word "unsigned"

Read-Only
Author
danish p.
Posted
25-Oct-2006 10:38 GMT
Toolset
C51
New! RE: It's a syntax error

i checked all the thing's and only after that posted the msg.
This could be a simple typo - eg, missing semicolon or spelling mistake.
there is no such type of mistake

Read-Only
Author
Andy Neil
Posted
25-Oct-2006 10:46 GMT
Toolset
C51
New! RE: It's a syntax error

"there is no such type of mistake"

Well, clearly there is - or you wouldn't get the error!

The error relates specifically tou your source text - so, if you want help with it, you are going to have to post that source!

Please be sure to read the instructions for posting code:
http://www.keil.com/forum/tips.asp

Use spaces to lay-out your code - not TABs (the interpretation of TABs is unpredictable).

Use copy-and-paste - do not manually re-type the code into your post!

Read-Only
Author
Andy Neil
Posted
25-Oct-2006 10:42 GMT
Toolset
C51
New! Parameter passing

"can any one explain me the passing the values between two function"

This is standard 'C' - nothing specifically to do with Keil at all.
Therefore, any 'C' textbook should be able to help you.

See: http://c-faq.com/style/srcfiles.html and the associated links

Read-Only
Author
danish p.
Posted
25-Oct-2006 11:05 GMT
Toolset
C51
New! RE: Parameter passing

thank's andy
but when i face the problem i done the each and every thing for which i capable but i can not get the way to of it.

here i providing the sample or small model fo the problematic code hope u will help me


unsigned int i,j,k,l,a;
unsigned int sft = 1;




void disp(unsigned int a);

unsigned int go (void);

/*interrupt setting (routine)***/

void TMR_0(void) interrupt 1
     {
     TF0  = 0;
         TR0  = 0;
         TH0  = 0xAA;

     disp(unsigned int);

         TL0  = 0x00;
         TR0  = 1;
     }

void disp(unsigned int a)
     {
     sft = a;

     DECOD1 = 0;        /* 7-segment 1st display */
     DECOD2 = 0;
     DECOD3 = 0;

     P0 = number_code[i];
         if(sft != 1)
           {disp_wait();}
         blink();
     }



/**** main prog******/

void main()
     {
         P0   = 0x3f; /* initial  port setting */
         P1   = 0xff;
         P2   = 0xf8;
         P3   = 0xff;

         IE   = 0x82;/*timer and interrept setting*/
         TMOD = 0x01;
          TH0  = 0xAA;
           TL0  = 0x00;
         TR0 =  1;

     while(1)
             {
             unsigned int go();
             }
    }

unsigned int go()
     {
/***shift key press identification *********/

         if(KEY2_SFT == 0)
           {
           sft++;
           sft_wait();
            KEY2_SFT = 1;
           if(sft > 4)
             {sft = 1;}
            a = sft;
            return(a);
           }


unnessary code is omited
can any one suggest the nessary change in this code.

Read-Only
Author
Andy Neil
Posted
25-Oct-2006 11:07 GMT
Toolset
C51
New! RE: error C141: syntax error near 'unsigned'

Where, precisely, does error C141: syntax error near 'unsigned' occur in this code?

Read-Only
Author
danish p.
Posted
25-Oct-2006 11:10 GMT
Toolset
C51
New! RE: error C141: syntax error near 'unsigned'

/*interrupt setting (routine)***/

void TMR_0(void) interrupt 1
     {
     TF0  = 0;
         TR0  = 0;
         TH0  = 0xAA;

     disp(unsigned int);  at this point

         TL0  = 0x00;
         TR0  = 1;
     }
</prr>


Read-Only
Author
Andy Neil
Posted
25-Oct-2006 11:16 GMT
Toolset
C51
New! RE: error C141: syntax error near 'unsigned'

Well, the error should be obvious!

But we've all been at that point of staring at a piece of code for so long that we can no longer see the wood for the trees!

So, back to basics: how do you call a function in 'C'?
How do you supply parameters when you call a fucntion in 'C' - what should go within the parentheses...?

What is the value or variable that you actually want to pass to the display() function at this point...?

Read-Only
Author
danish p.
Posted
25-Oct-2006 11:22 GMT
Toolset
C51
New! RE: error C141: syntax error near 'unsigned'
unsigned int go()
     {
/***shift key press identification *********/

         if(KEY2_SFT == 0)
           {
           sft++;
           sft_wait();
            KEY2_SFT = 1;
           if(sft > 4)
             {sft = 1;}
            a = sft; i want to pass this value
            return(a);
           }


/*********************************************/

disp(unsigned int);  at this point
Read-Only
Author
Andy Neil
Posted
25-Oct-2006 11:29 GMT
Toolset
C51
New! Passing parameters in 'C'

OK, let's take this one step at a time.

How do you pass a parameter to a function when you call it?

Insert an appropriate call to my_function in the code below, passing fred as its parameter:

void my_function( unsigned int x ); // function prototype

void main( void )
{
   unsigned int fred;

   // Insert a call here

}
Read-Only
Author
danish p.
Posted
25-Oct-2006 11:39 GMT
Toolset
C51
New! RE: Passing parameters in 'C'
void disp(unsigned int a);
//it going to used in the interrupt

unsigned int go (void);
//going to used in main function


void main()
     {
         P0   = 0x3f; /* initial  port setting */
         P1   = 0xff;
         P2   = 0xf8;
         P3   = 0xff;

         IE   = 0x82;/*timer and interrept setting*/
         TMOD = 0x01;
          TH0  = 0xAA;
           TL0  = 0x00;
         TR0 =  1;

     while(1)
             {
             unsigned int go();
             }
    }

void my_function( unsigned int x ); // function prototype


void main( void ) { unsigned int fred;
my_function(unsigned int);// Inserted a call here
}
Read-Only
Author
Andy Neil
Posted
25-Oct-2006 11:47 GMT
Toolset
C51
New! Right back to basics

OK. you are struggling with the basics of calling a function in 'C'.

You need to set aside your code, and concentrate just on the basic concept of calling a function - any function - and passing a parameter to it.

There is no point in trying to go any further before you have mastered this fundamental concept.

Hint: Look-up "formal" and "actual" parameters in your 'C' textbook.

Then try the exercise again:

Insert an appropriate call to my_function in the code below, passing fred as its parameter:

void my_function( unsigned int x ); // function prototype

void main( void )
{
   unsigned int fred;

   // Insert a call here

}
Read-Only
Author
danish p.
Posted
25-Oct-2006 11:52 GMT
Toolset
C51
New! RE: Right back to basics


Insert an appropriate call to my_function in the code below, passing fred as its parameter:

then

void my_function( unsigned int x ); // function prototype
void main( void )
{
unsigned int fred;
my_function(unsigned int fred);// Inserted a call here
}


Read-Only
Author
Andy Neil
Posted
25-Oct-2006 11:59 GMT
Toolset
C51
New! RE: Right back to basics

Did you compile it?
What did the compiler say?

What does your 'C' text book say about calling functions?
Specifically, what should go inside the brackets?

Read-Only
Author
danish p.
Posted
25-Oct-2006 12:04 GMT
Toolset
C51
New! RE: Right back to basics

as far as this e.g. concern the value assigned to fred is going to used in the my_function.i.e. it passing to through the basket and used by the function

Read-Only
Author
Andy Neil
Posted
25-Oct-2006 12:09 GMT
Toolset
C51
New! yes, so...

"the value assigned to fred is going to used in the my_function"

Yes, so if you want the value of 'fred' to be passed through to the function, what do you put inside the brackets in the function call?

Hint: the type of 'fred' has already been defined in the line

unsigned int fred;

So the compiler already knows what type 'fred' is - you don't have to specify it again, do you...?

Read-Only
Author
danish p.
Posted
25-Oct-2006 12:20 GMT
Toolset
C51
New! RE: yes, so...
void my_function( unsigned int x ); // function prototype
void main( void )
{
unsigned int fred;
my_function(fred);// it is ok now 
}

but now it genrates warnning, and not going to execute the which executes before the change's

 while(1)
 {
 unsigned int go();this function of the code
 }


WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS

Read-Only
Author
Andy Neil
Posted
25-Oct-2006 12:24 GMT
Toolset
C51
New! Progress!

Correct!

Do you now understand what the problem was?

"but now it genrates warnning"

That is actually progress!
Before, it didn't even compile - now it does compile, but gives this warning.

You need to post the full text of the message (remember: copy-and-paste) - it will include the name of the segment that is "uncalled"

Read-Only
Author
danish p.
Posted
25-Oct-2006 12:39 GMT
Toolset
C51
New! RE: Progress!

her is the full code with warnning

#include<reg52.h>
#include<define.h>
#include<intrins.h>

/*function declaration*/

void blink(void);
void disp_wait(void);
void disp_inc_wait(void);
void sft_wait(void);
void disp(unsigned int a);
void blink(void);
unsigned int go (void);

/*************************/

unsigned char number_code[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned int i,j,k,l,a;
unsigned int sft;//  = 1;


/* interrupt setting (routine)*/

void TMR_0(void) interrupt 1
     {
     TF0  = 0;
         TR0  = 0;
         TH0  = 0xAA;

     disp(a);

         TL0  = 0x00;
         TR0  = 1;
     }

void disp(unsigned int a)
     {
     sft = a;
     DECOD1 = 0;/**** 7-segment 1st display *******/
     DECOD2 = 0;
     DECOD3 = 0;

     P0 = number_code[i];
         if(sft != 1)
           {disp_wait();}
         blink();


     DECOD1 = 1;/*** 7-segment 2nd display *******/
     DECOD2 = 0;
     DECOD3 = 0;

     P0 = number_code[j];
     if(sft != 2)
           {disp_wait();}
         blink();


     DECOD1 = 0;/* 7-segment 3rd display ****/
     DECOD2 = 1;
     DECOD3 = 0;

     P0 = number_code[k];
     if(sft != 3)
           {disp_wait();}
         blink();


     DECOD1 = 1;/** 7-segment 4th display *****/
     DECOD2 = 1;
     DECOD3 = 0;

     P0 = number_code[l];
     if(sft != 4)
           {disp_wait();}
         blink();

        }


/***dly routine's*************/


void disp_wait()
         {
         unsigned int w1 = 0;
         unsigned int w2 = 0;
         for(w1 = 1;w1<=2;w1++)
            {
                for(w2 = 1;w2<=200;w2++)
                {}
                }
     }

void disp_inc_wait()
     {
         unsigned int w1 = 0;
         unsigned int w2 = 0;
         for(w2 = 1;w2 <=60;w2++)
        {
                for(w1 = 1;w1 <=800;w1++)
                   {
                   _nop_();
                   }
                }
     }

void sft_wait()
    {
    unsigned int w1 = 0;
        unsigned int w2 = 0;
        for(w2 = 1;w2 <=100;w2++)
        {
                for(w1 = 1;w1 <=800;w1++)
                   {_nop_();}
                }
        }

/****blink char(dly)******/

void blink()
    {
        unsigned int w1 = 0;
        unsigned int w2 = 0;
        for(w2 = 1; w2<=20; w2++)
        {
         sft_wait();
            }
     }

/****** main prog******/

void main()
     {
         P0   = 0x3f; /* initial  port setting */
         P1   = 0xff;
         P2   = 0xf8;
         P3   = 0xff;

        IE   = 0x82;/*timer and interrept setting  */
        TMOD = 0x01;
         TH0  = 0xAA;
         TL0  = 0x00;
        TR0 =  1;

     while(1)
             {
             unsigned int go();WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS

             }
}

unsigned int go()
     {
/*shift key press identification ****/

         if(KEY2_SFT == 0)
                   {
                   sft++;
                   sft_wait();
           KEY2_SFT = 1;
                   if(sft > 4)
                     {sft = 1;}
           }
/* opration on shift char ***/
         switch(sft)
               {
              case 1: /****** 7-segment 1st *******/
                   if(KEY1_INC == 0)
                     {
                      i++;
                     if(i > 9)
                       {i = 0;}
                      disp_inc_wait();
                     KEY1_INC = 1;
                     }
                     break;

                    case 2:
          if(KEY1_INC == 0)        /* 7-segment 2nd */
           {
           j++;
           if(j > 9)
               {j = 0;}
           disp_inc_wait();
            KEY1_INC = 1;
           }
           break;

         case 3:
          if(KEY1_INC == 0)/* 7-segment 3rd ***/
            {
            k++;
             if(k > 9)
              {k = 0;}
            disp_inc_wait();
            KEY1_INC = 1;
            }
         break;

        case 4:
           if(KEY1_INC == 0)/* 7-segment 4th */
             {
             l++;
              if(l > 9)
              {l = 0;}
             disp_inc_wait();
             KEY1_INC = 1;
             }
             break;
       }
         a = sft;
     return(a);
         }
Read-Only
Author
Andy Neil
Posted
25-Oct-2006 12:58 GMT
Toolset
C51
New! Not a compiler warning

Why do you think it's associated with that particular line?

This is a Linker warning - that's why it begins with an 'L'
It is not related to a specific 'C' source line!

The full text of the message looks like this:
http://www.keil.com/support/man/docs/lx51/lx51_l16.htm

Or this:
http://www.keil.com/support/man/docs/bl51/bl51_l16.htm

You have omitted to post the important bit - which is the segment-name

The segment-name tells you what it is that the Linker thinks is uncalled...

Read-Only
Author
danish p.
Posted
25-Oct-2006 13:08 GMT
Toolset
C51
New! RE: Not a compiler warning

i m very very thank full to you for guiding me.
as problem is solved fully(no error by changing the type defn and warnning by giving or alloting the returned value to other variable and from that varible the value is collected at the other end )
this help's me alot but not able to give the output as i required i have to think in other way again thank's for u r help

Read-Only
Author
Andy Neil
Posted
25-Oct-2006 13:15 GMT
Toolset
C51
New! RE: Not a compiler warning

"i have to think in other way again "

I think you need to take a step back and review the basics of programming in 'C'

Read-Only
Author
danish p.
Posted
25-Oct-2006 11:56 GMT
Toolset
C51
New! RE: Right back to basics

here the "actual" parameter is fred

and the "formal" parameter is x

Read-Only
Author
Andy Neil
Posted
25-Oct-2006 12:01 GMT
Toolset
C51
New! Good

"here the 'actual' parameter is fred
and the 'formal' parameter is x"

Yes - good!

Now, what should go inside the brackets in the call to the function?

Read-Only
Author
danish p.
Posted
25-Oct-2006 12:09 GMT
Toolset
C51
New! RE: Good

as far as this e.g. concern the value assigned to fred is going to used in the my_function.i.e. it passing to through the basket and used by the function

Read-Only
Author
alan kneil
Posted
26-Oct-2006 11:19 GMT
Toolset
C51
New! RE: Good

Hats off to you,

so much of patience, explaining or coaching him, (wish you could coach me, :)

suggest you write the whole thing for him and charge your royalty;
right ... ?

Read-Only
Author
ham nell
Posted
26-Oct-2006 11:47 GMT
Toolset
C51
New! RE: Good

seems the better option,
meanwhile he could work out your same code taking one function at a time to fulfill any curiosity

rihgt na,

Read-Only
Author
alan kneil
Posted
26-Oct-2006 11:25 GMT
Toolset
C51
New! RE: Good

Andy,
have been reading this forum questions n ur answers with interest,

is there a way to contact you,

thanks n rgds,
alan.

Next Thread | Thread List | Previous Thread Start a Thread | Settings

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.