Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

RE: [lpc2000] Strange Compiler Behaviour -

2005-02-23 by Paul Curtis

Hi, 

> extern IDINFO que_ids[]; and extern IDINFO *que_ids; should 
> be equivalent as far as I am aware and this is the first 
> instance where I have found two compilers producing 
> completely different code (one seemingly false).

They certainly are NOT equivalent!  The first says that que_ids is an
array of IDINFO elements based at que_ids (e.g. an array starting at
0x4000).  The second says que_ids is a pointer to a IDINFO based at
que_ids (e.g. at 0x4000 there is a pointer to an array).

You can boil this down really easily:

static int xa[10];
static int *xp;
extern int xae[];

// Assign the address of I to the pointer P
xp = &i;

// Try doing that with an array
xa = &i;  // won't have it.

// Or an external unspecified array
xae = &i;  // won't have it.

Simple.  User error.

--
Paul Curtis, Rowley Associates Ltd  http://www.rowley.co.uk
CrossWorks for MSP430, ARM, AVR and (soon) MAXQ processors

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.