static 
Author Message
 static

I have this code:
I do not understand why 'static' is used  here, see arrow. Could you
help me please. Thanks a lot in advance.

#include "gdefs.h"
#include "eprom.h"
static byte EPROMtype;
#define ReserveredRAMlen 0x100
static union {byte RAM[ReserveredRAMlen];     <--------- here
              void (*Proc)();} Reserved;
static void CopyEPROMtoRAM(byte *Proc)        <-------- here

  word i;
  byte *RAMptr;

  RAMptr = &Reserved.RAM[0];
  for (i=0; i<ReserveredRAMlen; i++)
  { *RAMptr = *Proc;
    RAMptr++;
    Proc++;
/*   This routine tries to get the EPROM manufacture code bytes from  
*/
/* the currently installed EPROM.  This routine must run out of RAM as
*/
/* the routine disables EPROM normal read access. This is the RAM part
*/
/* for EPROMgetManufactureCode().                                    
*/
{
  byte *FirstAddr, *SecondAddr, *ThirdAddr;

  /* Test for Advanced Micro devices (AMD), Part #: 29F010-120ET */
  FirstAddr = (byte *) 0x5555;
  SecondAddr = (byte *) 0x2AAA;

  DisableInterrupts;
  *FirstAddr = 0xAA;
  *SecondAddr = 0x55;
  *FirstAddr = 0x90;air of
  ThirdAddr = (byte *) 0x0000;
  TypeBuf[1] = *ThirdAddr; /* Get Manufacture's Code */
  ThirdAddr = (byte *) 0x0001;
  TypeBuf[2] = *ThirdAddr; /* Get Device Type */

  /* We'll just assume that we've got the code and return with it.    */
  /* Perhaps this could be made more robust by reading the data       */
  /* at 0x0000 & 0x0001 while still in read mode to ensure it isn't a */
  /* the same as the data returned in AutoSelect Mode. If the data is */
  /* the same then maybe we could try different paair of addresses.  
*/
  }

Quote:
}/* CopyEPROMtoRAM */



Fri, 07 Jan 2000 03:00:00 GMT  
 static

Quote:

>I have this code:
>I do not understand why 'static' is used  here, see arrow. Could you
>help me please. Thanks a lot in advance.

>#include "gdefs.h"
>#include "eprom.h"
>static byte EPROMtype;

Do you understand this one? This defines an object called EPROMbyte of type
byte that has internal linkage. The important effect of that here is that
the object can't be referenced by name in any other (separately compiled)
source file.

Quote:
>#define ReserveredRAMlen 0x100
>static union {byte RAM[ReserveredRAMlen];     <--------- here
>              void (*Proc)();} Reserved;

This defines an object called Reserved of the specified union type. static
here has the same effect as above i.e. the object can't be referenced by
name in any other source file.

Quote:
>static void CopyEPROMtoRAM(byte *Proc)        <-------- here

CopyEPROMtoRAM in this case is a function but the effect of static is the
same i.e. the function can't be referenced by name in another source file.
To put it another way, unless you start passing function pointers around,
CopyEPROMtoRAM() can only be called from within this source file.

--
-----------------------------------------


-----------------------------------------



Fri, 07 Jan 2000 03:00:00 GMT  
 static

: I have this code:
: I do not understand why 'static' is used  here, see arrow. Could you
: help me please. Thanks a lot in advance.

: #include "gdefs.h"
: #include "eprom.h"
: static byte EPROMtype;
: #define ReserveredRAMlen 0x100
: static union {byte RAM[ReserveredRAMlen];     <--------- here
:               void (*Proc)();} Reserved;
: static void CopyEPROMtoRAM(byte *Proc)        <-------- here

Assuming you nuked the { starting this function, both
statics are for the same reason: so these functions are
not visible outside of the current source file.

Scott

PS: I'm curious as to why you had no problem with the
static byte, to be honest.



Fri, 07 Jan 2000 03:00:00 GMT  
 static


Quote:
>I have this code:
>I do not understand why 'static' is used  here, see arrow. Could you
>help me please. Thanks a lot in advance.

>#include "gdefs.h"
>#include "eprom.h"
>static byte EPROMtype;
>#define ReserveredRAMlen 0x100
>static union {byte RAM[ReserveredRAMlen];     <--------- here
>              void (*Proc)();} Reserved;

It's used so that the object being declared (``Reserved'') has internal
linkage: that is, the symbol is only available for linkage within the
translation unit where it is defined.

Quote:
>static void CopyEPROMtoRAM(byte *Proc)        <-------- here

Again, this has the effect that CopyEPROMtoRAM is visible only to the
current translation unit. It is, in-effect, a private function.


Fri, 07 Jan 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Static and non-Static member - Signature

2. Why there is no static destructor corresponding to static constructor

3. Creating a static class from non static Framework classes

4. struct initialization (with static, const static members)

5. Pointers to non-static vs static functions

6. One Problem in Calling Static function from Non static function

7. static pointer to static array

8. static versus non static returnvalues

9. static -> static near

10. vc wouldn't initialize static members in static libraries

11. Static library linked within other Static LIB?

12. Static array containing non static objects and functions

 

 
Powered by phpBB® Forum Software