Skip to contentSkip to conversation

Why cmd_tbl_t is referenced as extern in defining __u_boot_cmd_start?

U-Boot legendbb 2 participants 2 messages Nov 2, 2010 – Nov 9, 2010

lore
Share & tools
lore

legendbb

author
#0 lore raw

line 64 and 65 in include/command.h

extern cmd_tbl_t __u_boot_cmd_start;
extern cmd_tbl_t __u_boot_cmd_end;

definition of cmd_tbl_t is just one line above these. Why "extern" is used?

Thanks,

struct cmd_tbl_s {
	char		*name;		/* Command Name			*/
	int		maxargs;	/* maximum number of arguments	*/
	int		repeatable;	/* autorepeat allowed?		*/
					/* Implementation function	*/
	int		(*cmd)(struct cmd_tbl_s *, int, int, char *[]);
	char		*usage;		/* Usage message	(short)	*/
#ifdef	CONFIG_SYS_LONGHELP
	char		*help;		/* Help  message	(long)	*/
#endif
#ifdef CONFIG_AUTO_COMPLETE
	/* do auto completion on the arguments */
	int		(*complete)(int argc, char *argv[], char last_char, int maxv, char

*cmdv[]);
#endif
};

typedef struct cmd_tbl_s cmd_tbl_t;

extern cmd_tbl_t __u_boot_cmd_start;
extern cmd_tbl_t __u_boot_cmd_end;

Signature · 2 lines
View this message in context: http://old.nabble.com/Why-cmd_tbl_t-is-referenced-as-extern-in-defining-__u_boot_cmd_start--tp30115036p30115036.html
Sent from the Uboot - Users mailing list archive at Nabble.com.
#1 lore raw
Quoted 6 lines · On Tuesday, November 02, 2010 11:56:31 legendbb wrote:

line 64 and 65 in include/command.h

extern cmd_tbl_t __u_boot_cmd_start;
extern cmd_tbl_t __u_boot_cmd_end;

definition of cmd_tbl_t is just one line above these. Why "extern" is used?

basic C question ? if you dont have the extern, you'd be declaring storage for two variables instead of references to the symbols elsewhere.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20101109/31e53fee/attachment.pgp