This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

v6.23: Problem with static bit and SRC directive

I've just installed the C51 Update v6.23:
http://www.keil.com/forum/msgpage.asp?MsgID=4908

I have a 'C' function with an initialised local static bit, in a source file compiled with the SRC directive:

void fred()
{
   static bit initialise = TRUE;

   if( initialise )
   {
      initialise = FALSE;
      :
      :
      etc

It worked fine in v6.14, but v6.23 forgets to define the bit and, therefore, gives A45 Errors, "UNDEFINED SYMBOL (PASS-2)," at every reference!

It might only happen when the local static bit definition has an initialiser?

Parents
  • Andrew, the following program compiles with no diagnostics using every optimization level. Can you modify it so that it fails like your REAL code?

    void fred (void)
    {
       static bit initialise = 1;
    
       if( initialise )
       {
          initialise = 0;
       }
    }
    
    
    void main (void)
    {
    fred ();
    }
    

    Thanks,

    Jon

Reply
  • Andrew, the following program compiles with no diagnostics using every optimization level. Can you modify it so that it fails like your REAL code?

    void fred (void)
    {
       static bit initialise = 1;
    
       if( initialise )
       {
          initialise = 0;
       }
    }
    
    
    void main (void)
    {
    fred ();
    }
    

    Thanks,

    Jon

Children
  • Did you use the SRC directive, and Assemble the resulting .SRC?

    The error message is reported by the Assembler; the 'C' compilation completes with no diagnostics.

    (I don't have v6.23 to hand at the moment)

  • I have the same problem.!

    =============================
    void func(void)
    {
    static unsigned char var1;
    ...
    switch(var1){
    ...
    }
    }
    ==============================
    and the error message is
    "error A45 : Undefined Symbol (PASS-2)"
    at the static variable 'var1'.

    I know it is compiled well with C51 and also
    got func.src file using SRC directive.

    but the error message is occured by assembler too.
    (using v6.23)

    Andrew ?
    Did you solve this problem?

    Thanks.
    Joon.

  • "Did you solve this problem?"

    I'm pretty sure this was a compiler bug (it's a long time ago now!).

    The earliest C51 version I now use is v6.23a!

  • Most of all, I appreciate for your reply.

    Now, I use C51 V6.23a and uvision V2.23 too.
    The error message didnot occur If I dont declare the local static variable in the functions as below.

    =============================
    static unsigned char var1;
    static unsigned char var2;

    void func_1(void)
    {
    ...
    switch(var1){
    ...
    }
    }

    void func_2(void)
    {
    ...
    switch(var2) {
    ...
    }
    }
    ==============================

    but i wanna to declare these as local static variable in the functions.

    Have to I update new verstion?
    If I dont update C51 , cant I solve this problem?

    Regards.

    Joon