CHAPTER 9 : Data Usage
PART 4 : USAGE
CHAPTER 9 : Data Usage
9.1 Declarations
9.2 Using floating point numbers
9.3 Using 'typedef'
9.4 Using global data
9.5 Using Structures
9.6 Using Unions
9.7 Using Arrays
9.8 Using Pointers
9.9 Using bit structures
9.10 Using Constants
9.11 Using 'static' declarations
9.12 Initializing variables
9.13 Summary
<--Prev page | Next page -->
9.11 Using 'static' declarations
Data items and functions which are only referenced within a single file may
be declared static, to limit their scope to this file only. This can be annoying
when debugging, as a static name may not appear in the external symbol map, and
the item can consequently not be found. A solution is:
/* common.h */
#ifdef DEBUGGING
# define PRIVATE /* make private items public */
#else
# define PRIVATE static /* make private items private */
#endif
/* kbdread.c */
#include "common.h"
...
PRIVATE int LastStatus;
-----------------------------------------------------------------------
This does go against the principle of not redefining the language, but it can
provide a standard solution to the static vs. debuggable problem.
<--Prev page | Next page -->
|