diff --git a/apps/app_externalivr.c b/apps/app_externalivr.c
index 3a8f0a95d0a0c630ff474938a8728e278441b0d9..3a3644923bf5187e3f440a79258ef500a1329443 100644
--- a/apps/app_externalivr.c
+++ b/apps/app_externalivr.c
@@ -95,11 +95,11 @@ static const char app[] = "ExternalIVR";
 /* XXX the parser in gcc 2.95 gets confused if you don't put a space between 'name' and the comma */
 #define ast_chan_log(level, channel, format, ...) ast_log(level, "%s: " format, channel->name , ## __VA_ARGS__)
 
-enum {
+enum options_flags {
 	noanswer = (1 << 0),
 	ignore_hangup = (1 << 1),
 	run_dead = (1 << 2),
-} options_flags;
+};
 
 AST_APP_OPTIONS(app_opts, {
 	AST_APP_OPTION('n', noanswer),
diff --git a/apps/app_fax.c b/apps/app_fax.c
index 8f98af2e77bcdb03aaa17dde8575c78ce8f06557..bd6bdf9f63de5eea6c3acfcfd05706a291d938dc 100644
--- a/apps/app_fax.c
+++ b/apps/app_fax.c
@@ -351,7 +351,7 @@ static int fax_generator_generate(struct ast_channel *chan, void *data, int len,
 	return 0;
 }
 
-struct ast_generator generator = {
+static struct ast_generator generator = {
 	alloc:		fax_generator_alloc,
 	generate: 	fax_generator_generate,
 };
diff --git a/apps/app_macro.c b/apps/app_macro.c
index f3a6b546e23b8904366f99d6e8c68eea6542734c..e48d3c361976f2345fd78737026f853818098b00 100644
--- a/apps/app_macro.c
+++ b/apps/app_macro.c
@@ -159,7 +159,7 @@ static char *exit_app = "MacroExit";
 
 static void macro_fixup(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan);
 
-struct ast_datastore_info macro_ds_info = {
+static struct ast_datastore_info macro_ds_info = {
 	.type = "MACRO",
 	.chan_fixup = macro_fixup,
 };
diff --git a/apps/app_minivm.c b/apps/app_minivm.c
index afbd9dc2ea4d4ba45b2b4c549a1d9569606612af..ac48aa50fc8e6b39deac9a3bfdb743a9965986c4 100644
--- a/apps/app_minivm.c
+++ b/apps/app_minivm.c
@@ -548,19 +548,19 @@ static char *app_minivm_mwi = "MinivmMWI";
 
 
 
-enum {
+enum minivm_option_flags {
 	OPT_SILENT =	   (1 << 0),
 	OPT_BUSY_GREETING =    (1 << 1),
 	OPT_UNAVAIL_GREETING = (1 << 2),
 	OPT_TEMP_GREETING = (1 << 3),
 	OPT_NAME_GREETING = (1 << 4),
 	OPT_RECORDGAIN =  (1 << 5),
-} minivm_option_flags;
+};
 
-enum {
+enum minivm_option_args {
 	OPT_ARG_RECORDGAIN = 0,
 	OPT_ARG_ARRAY_SIZE = 1,
-} minivm_option_args;
+};
 
 AST_APP_OPTIONS(minivm_app_options, {
 	AST_APP_OPTION('s', OPT_SILENT),
@@ -670,7 +670,7 @@ static struct minivm_stats global_stats;
 AST_MUTEX_DEFINE_STATIC(minivmlock);	/*!< Lock to protect voicemail system */
 AST_MUTEX_DEFINE_STATIC(minivmloglock);	/*!< Lock to protect voicemail system log file */
 
-FILE *minivmlogfile;			/*!< The minivm log file */
+static FILE *minivmlogfile;		/*!< The minivm log file */
 
 static int global_vmminmessage;		/*!< Minimum duration of messages */
 static int global_vmmaxmessage;		/*!< Maximum duration of message */
diff --git a/apps/app_mixmonitor.c b/apps/app_mixmonitor.c
index d6e4ed044f14c173e116f1fd376adb936e3325dd..d4b8519cb678dc2cb245154656da9f1be68f2dd0 100644
--- a/apps/app_mixmonitor.c
+++ b/apps/app_mixmonitor.c
@@ -132,8 +132,6 @@ static const char * const app = "MixMonitor";
 
 static const char * const stop_app = "StopMixMonitor";
 
-struct module_symbols *me;
-
 static const char * const mixmonitor_spy_type = "MixMonitor";
 
 struct mixmonitor {
@@ -145,20 +143,20 @@ struct mixmonitor {
 	struct ast_autochan *autochan;
 };
 
-enum {
+enum mixmonitor_flags {
 	MUXFLAG_APPEND = (1 << 1),
 	MUXFLAG_BRIDGED = (1 << 2),
 	MUXFLAG_VOLUME = (1 << 3),
 	MUXFLAG_READVOLUME = (1 << 4),
 	MUXFLAG_WRITEVOLUME = (1 << 5),
-} mixmonitor_flags;
+};
 
-enum {
+enum mixmonitor_args {
 	OPT_ARG_READVOLUME = 0,
 	OPT_ARG_WRITEVOLUME,
 	OPT_ARG_VOLUME,
 	OPT_ARG_ARRAY_SIZE,
-} mixmonitor_args;
+};
 
 AST_APP_OPTIONS(mixmonitor_opts, {
 	AST_APP_OPTION('a', MUXFLAG_APPEND),
diff --git a/apps/app_page.c b/apps/app_page.c
index b277dab560c2234356280039fe7dc7e4189b31ff..04f9f98c50dd7259f485ea0eba7c4717d10da0b2 100644
--- a/apps/app_page.c
+++ b/apps/app_page.c
@@ -101,13 +101,13 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
  ***/
 static const char * const app_page= "Page";
 
-enum {
+enum page_opt_flags {
 	PAGE_DUPLEX = (1 << 0),
 	PAGE_QUIET = (1 << 1),
 	PAGE_RECORD = (1 << 2),
 	PAGE_SKIP = (1 << 3),
 	PAGE_IGNORE_FORWARDS = (1 << 4),
-} page_opt_flags;
+};
 
 AST_APP_OPTIONS(page_opts, {
 	AST_APP_OPTION('d', PAGE_DUPLEX),
diff --git a/apps/app_queue.c b/apps/app_queue.c
index e32caa78d19093746616db1f2ddca2709aeadc0f..bebe543b80a7b6bd8527abeae23bbfbd4d4e8714 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -977,7 +977,7 @@ struct rule_list {
 	AST_LIST_ENTRY(rule_list) list;
 };
 
-AST_LIST_HEAD_STATIC(rule_lists, rule_list);
+static AST_LIST_HEAD_STATIC(rule_lists, rule_list);
 
 static struct ao2_container *queues;
 
diff --git a/apps/app_read.c b/apps/app_read.c
index 3e22d2ef8b17eaf7fd9c8845a0103ba5269cabb7..a5e4a64342d501974ec6e36faa6f8262e5719f47 100644
--- a/apps/app_read.c
+++ b/apps/app_read.c
@@ -108,11 +108,11 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 	</application>
  ***/
 
-enum {
+enum read_option_flags {
 	OPT_SKIP = (1 << 0),
 	OPT_INDICATION = (1 << 1),
 	OPT_NOANSWER = (1 << 2),
-} read_option_flags;
+};
 
 AST_APP_OPTIONS(read_app_options, {
 	AST_APP_OPTION('s', OPT_SKIP),
diff --git a/apps/app_readexten.c b/apps/app_readexten.c
index ef59aa5380f03b630ba5026cbd040b766274c0d3..b6b6305a524b4e9d6acc0728fa57fe031edc9075 100644
--- a/apps/app_readexten.c
+++ b/apps/app_readexten.c
@@ -111,11 +111,11 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 	</function>
  ***/
 
-enum {
+enum readexten_option_flags {
 	OPT_SKIP = (1 << 0),
 	OPT_INDICATION = (1 << 1),
 	OPT_NOANSWER = (1 << 2),
-} readexten_option_flags;
+};
 
 AST_APP_OPTIONS(readexten_app_options, {
 	AST_APP_OPTION('s', OPT_SKIP),
diff --git a/apps/app_skel.c b/apps/app_skel.c
index 1796ab4f5bd79c80ae67c2e3d4a915e01a5ed5df..c58d451e406df62eb7df802e60e1c0df1e104b71 100644
--- a/apps/app_skel.c
+++ b/apps/app_skel.c
@@ -74,18 +74,18 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 static char *app = "Skel";
 
-enum {
+enum option_flags {
 	OPTION_A = (1 << 0),
 	OPTION_B = (1 << 1),
 	OPTION_C = (1 << 2),
-} option_flags;
+};
 
-enum {
+enum option_args {
 	OPTION_ARG_B = 0,
 	OPTION_ARG_C = 1,
 	/* This *must* be the last value in this enum! */
 	OPTION_ARG_ARRAY_SIZE = 2,
-} option_args;
+};
 
 AST_APP_OPTIONS(app_opts,{
 	AST_APP_OPTION('a', OPTION_A),
diff --git a/apps/app_sms.c b/apps/app_sms.c
index a0e0c2fc0106cfd390a745cfd32e2a3e68d8135a..78af84926476327aa479cd7824b6b24e62b12020 100644
--- a/apps/app_sms.c
+++ b/apps/app_sms.c
@@ -1832,19 +1832,19 @@ static void sms_process(sms_t * h, int samples, signed short *data)
  *	- AST_APP_OPTIONS() to drive the parsing routine
  *	- in the function, AST_DECLARE_APP_ARGS(...) for the arguments.
  */
-enum {
+enum sms_flags {
 	OPTION_BE_SMSC	= (1 << 0),             /* act as sms center */
 	OPTION_ANSWER	= (1 << 1),             /* answer on incoming calls */
 	OPTION_TWO	= (1 << 2),                 /* Use Protocol Two */
 	OPTION_PAUSE	= (1 << 3),             /* pause before sending data, in ms */
 	OPTION_SRR	= (1 << 4),                 /* set srr */
 	OPTION_DCS	= (1 << 5),                 /* set dcs */
-} sms_flags;
+};
 
-enum {
+enum sms_opt_args {
 	OPTION_ARG_PAUSE = 0,
 	OPTION_ARG_ARRAY_SIZE
-} sms_opt_args;
+};
 
 AST_APP_OPTIONS(sms_options, {
 	AST_APP_OPTION('s', OPTION_BE_SMSC),
diff --git a/apps/app_stack.c b/apps/app_stack.c
index 100a59603a64d0489a122cdc3bac70d5e91e3753..84be40ba2ef6b03f258d77a07e3be86ad1285627 100644
--- a/apps/app_stack.c
+++ b/apps/app_stack.c
@@ -642,7 +642,7 @@ static int handle_gosub(struct ast_channel *chan, AGI *agi, int argc, const char
 	return RESULT_SUCCESS;
 }
 
-struct agi_command gosub_agi_command =
+static struct agi_command gosub_agi_command =
 	{ { "gosub", NULL }, handle_gosub, NULL, NULL, 0 };
 
 static int unload_module(void)
diff --git a/apps/app_url.c b/apps/app_url.c
index 234cff619649070129ecaf9dcd023a946d4dce78..a36daa26ba3a0ea2193e8b3b87df2aa26756da6e 100644
--- a/apps/app_url.c
+++ b/apps/app_url.c
@@ -82,9 +82,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 static char *app = "SendURL";
 
-enum {
+enum option_flags {
 	OPTION_WAIT = (1 << 0),
-} option_flags;
+};
 
 AST_APP_OPTIONS(app_opts,{
 	AST_APP_OPTION('w', OPTION_WAIT),
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 1c14f2e4fea222b56859c76626c008750445cf47..2655fc2ab7188f9b56b69b98de6242dcfea440af 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -425,16 +425,16 @@ static AST_LIST_HEAD_STATIC(vmstates, vmstate);
 #define ERROR_LOCK_PATH  -100
 
 
-enum {
+enum vm_box {
 	NEW_FOLDER,
 	OLD_FOLDER,
 	WORK_FOLDER,
 	FAMILY_FOLDER,
 	FRIENDS_FOLDER,
 	GREETINGS_FOLDER
-} vm_box;
+};
 
-enum {
+enum vm_option_flags {
 	OPT_SILENT =           (1 << 0),
 	OPT_BUSY_GREETING =    (1 << 1),
 	OPT_UNAVAIL_GREETING = (1 << 2),
@@ -444,15 +444,15 @@ enum {
 	OPT_DTMFEXIT =         (1 << 7),
 	OPT_MESSAGE_Urgent =   (1 << 8),
 	OPT_MESSAGE_PRIORITY = (1 << 9)
-} vm_option_flags;
+};
 
-enum {
+enum vm_option_args {
 	OPT_ARG_RECORDGAIN = 0,
 	OPT_ARG_PLAYFOLDER = 1,
 	OPT_ARG_DTMFEXIT   = 2,
 	/* This *must* be the last value in this enum! */
 	OPT_ARG_ARRAY_SIZE = 3,
-} vm_option_args;
+};
 
 AST_APP_OPTIONS(vm_app_options, {
 	AST_APP_OPTION('s', OPT_SILENT),
diff --git a/doc/CODING-GUIDELINES b/doc/CODING-GUIDELINES
index 5b7e75893b3d470c4aa8f29dc674e69bb2ccea4f..80ab2076756158f426e7f663f99501566c8024d9 100644
--- a/doc/CODING-GUIDELINES
+++ b/doc/CODING-GUIDELINES
@@ -114,7 +114,6 @@ those you really need. Apart from obvious cases (e.g. module.h which
 is almost always necessary) write a short comment next to each #include to
 explain why you need it.
 
-
 * Declaration of functions and variables
 ----------------------------------------
 
@@ -122,14 +121,46 @@ explain why you need it.
   since it is harder to read and not portable to GCC 2.95 and others.
 
 - Functions and variables that are not intended to be used outside the module
-  must be declared static.
+  must be declared static. If you are compiling on a Linux platform that has the
+  'dwarves' package available, you can use the 'pglobal' tool from that package
+  to check for unintended global variables or functions being exposed in your
+  object files. Usage is very simple:
+
+  $ pglobal -vf <path to .o file>
 
 - When reading integer numeric input with scanf (or variants), do _NOT_ use '%i'
   unless you specifically want to allow non-base-10 input; '%d' is always a better
   choice, since it will not silently turn numbers with leading zeros into base-8.
 
-- Strings that are coming from input should not be used as a first argument to
-  a formatted *printf function.
+- Strings that are coming from input should not be used as the format argument to
+  any printf-style function.
+
+* Structure alignment and padding
+---------------------------------
+
+On many platforms, structure fields (in structures that are not marked 'packed')
+will be laid out by the compiler with gaps (padding) between them, in order to
+satisfy alignment requirements. As a simple example:
+
+struct foo {
+       int bar;
+       void *xyz;
+}
+
+On nearly every 64-bit platform, this will result in 4 bytes of dead space between
+'bar' and 'xyz', because pointers on 64-bit platforms must be aligned on 8-byte
+boundaries. Once you have your code written and tested, it may be worthwhile to review
+your structure definitions to look for problems of this nature. If you are on a Linux
+platform with the 'dwarves' package available, the 'pahole' tool from that package
+can be used to both check for padding issues of this type and also propose reorganized
+structure definitions to eliminate it. Usage is quite simple; for a structure named 'foo',
+the command would look something like this:
+
+$ pahole --reorganize --show_reorg_steps -C foo <path to module>
+
+The 'pahole' tool has many other modes available, including some that will list all the
+structures declared in the module and the amount of padding in each one that could possibly
+be recovered.
 
 * Use the internal API
 ----------------------
diff --git a/include/asterisk/app.h b/include/asterisk/app.h
index da947b5d7149a44a0fcaee87429fe28da26bb6f4..3bf780060b9fffff746f7a6d548785709eacfb34 100644
--- a/include/asterisk/app.h
+++ b/include/asterisk/app.h
@@ -447,19 +447,19 @@ struct ast_app_option {
 
   Example usage:
   \code
-  enum {
+  enum my_app_option_flags {
         OPT_JUMP = (1 << 0),
         OPT_BLAH = (1 << 1),
         OPT_BLORT = (1 << 2),
-  } my_app_option_flags;
+  };
 
-  enum {
+  enum my_app_option_args {
         OPT_ARG_BLAH = 0,
         OPT_ARG_BLORT,
         !! this entry tells how many possible arguments there are,
            and must be the last entry in the list
         OPT_ARG_ARRAY_SIZE,
-  } my_app_option_args;
+  };
 
   AST_APP_OPTIONS(my_app_options, {
         AST_APP_OPTION('j', OPT_JUMP),