Yahoo Groups archive

Lpc2000

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

Thread

C Code Error Help

C Code Error Help

2006-04-02 by heedaf

I'm getting the following error in CrossWorks

         "multiple definition of `clear'" 

when I try and run the following code.  Does anyone have any 
suggestions?
Thanks,
Dewayne



#define SAMPLE  double      /* define the type used for data samples */


/**********************************************************************
******/
/* clear: zeroize a FIR delay 
line                                          */
/**********************************************************************
******/
void clear(int ntaps, SAMPLE z[])      
{
    int ii;
    for (ii = 0; ii < ntaps; ii++) 
    {
        z[ii] = 0;
    }
}

RE: [lpc2000] C Code Error Help

2006-04-02 by Michael Anton

> -----Original Message-----
> From: lpc2000@yahoogroups.com 
> [mailto:lpc2000@yahoogroups.com]On Behalf
> Of heedaf
> Sent: Sunday, April 02, 2006 4:21 PM
> To: lpc2000@yahoogroups.com
> Subject: [lpc2000] C Code Error Help
> 
> 
> I'm getting the following error in CrossWorks
> 
>          "multiple definition of `clear'" 
> 
> when I try and run the following code.  Does anyone have any 
> suggestions?
> Thanks,
> Dewayne
> 
> 
> 
> #define SAMPLE  double      /* define the type used for data 
> samples */
> 
> 
> /*************************************************************
> *********
> ******/
> /* clear: zeroize a FIR delay 
> line                                          */
> /*************************************************************
> *********
> ******/
> void clear(int ntaps, SAMPLE z[])      

<snip>

Make sure you have a function prototype somewhere before
the function definition, and before you call it.  i.e.:

void clear(int, SAMPLE);


I hope this helps,

Mike

Re: C Code Error Help

2006-04-02 by heedaf

> > I'm getting the following error in CrossWorks
> > 
> >          "multiple definition of `clear'" 
> > 
> > when I try and run the following code.  Does anyone have any 
> > suggestions?
> > Thanks,
> > Dewayne
> > 
> > 
> > 
> > #define SAMPLE  double      /* define the type used for data 
> > samples */
> > 
> > 
> > /*************************************************************
> > *********
> > ******/
> > /* clear: zeroize a FIR delay 
> > line                                          */
> > /*************************************************************
> > *********
> > ******/
> > void clear(int ntaps, SAMPLE z[])      
> 
> <snip>
> 
> Make sure you have a function prototype somewhere before
> the function definition, and before you call it.  i.e.:
> 
> void clear(int, SAMPLE);
> 
> 
> I hope this helps,
> 
> Mike
>

Still doesn't work.  I can compile ok but it gives me an error on 
the bracket under the function call.  Does it have anything to do 
with passing an array?  If so, any idea what the correct format is?

Re: C Code Error Help

2006-04-03 by heedaf

> > > > I'm getting the following error in CrossWorks
> > > > 
> > > >          "multiple definition of `clear'" 
> > > > 
> > > > when I try and run the following code.  Does anyone have any 
> > > > suggestions?
> > > > Thanks,
> > > > Dewayne
> > > > 
> > > > 
> > > > 
> > > > #define SAMPLE  double      /* define the type used for data 
> > > > samples */
> > > > 
> > > > 
> > > 
> /*************************************************************
> > > > *********
> > > > ******/
> > > > /* clear: zeroize a FIR delay 
> > > > line                                          */
> > > 
> /*************************************************************
> > > > *********
> > > > ******/
> > > > void clear(int ntaps, SAMPLE z[])      
> > > 
> > > <snip>
> > > 
> > > Make sure you have a function prototype somewhere before
> > > the function definition, and before you call it.  i.e.:
> > > 
> > > void clear(int, SAMPLE);
> > > 
> > 
> > 
> > Still doesn't work.  It will compile Ok but gives the above 
error.  
> > Does it have anyting to do with passing an array?  If so, what 
is 
> > the correct format?
> > 
> 
> Well, you really shouldn't try to pass the array.  Usually one 
would
> pass a pointer to the array.
> 
> It's also possible that clear is a name already used by CrossWorks
> somewhere.
> 
> When do you get the error?  Is it during compile, link, or debug?
> 
> Mike
>
*****************************************************
******************************************************
I put static in front of the function call and it will debug now.  
With my limited knowledge of C I'm not sure why this is the case.  I 
changed the function call name to ensure that it is an unique 
without any luck.  Any idea why static works?
Thanks for your help Mike,
Dewayne

RE: [lpc2000] Re: C Code Error Help

2006-04-03 by Michael Anton

> -----Original Message-----
> From: lpc2000@yahoogroups.com 
> [mailto:lpc2000@yahoogroups.com]On Behalf
> Of heedaf
> Sent: Sunday, April 02, 2006 5:30 PM
> To: lpc2000@yahoogroups.com
> Subject: [lpc2000] Re: C Code Error Help
> 
> 
> > > I'm getting the following error in CrossWorks
> > > 
> > >          "multiple definition of `clear'" 
> > > 
> > > when I try and run the following code.  Does anyone have any 
> > > suggestions?
> > > Thanks,
> > > Dewayne
> > > 
> > > 
> > > 
> > > #define SAMPLE  double      /* define the type used for data 
> > > samples */
> > > 
> > > 
> > > /*************************************************************
> > > *********
> > > ******/
> > > /* clear: zeroize a FIR delay 
> > > line                                          */
> > > /*************************************************************
> > > *********
> > > ******/
> > > void clear(int ntaps, SAMPLE z[])      
> > 
> > <snip>
> > 
> > Make sure you have a function prototype somewhere before
> > the function definition, and before you call it.  i.e.:
> > 
> > void clear(int, SAMPLE);
> > 
> 
> 
> Still doesn't work.  It will compile Ok but gives the above error.  
> Does it have anyting to do with passing an array?  If so, what is 
> the correct format?
> 

Well, you really shouldn't try to pass the array.  Usually one would
pass a pointer to the array.

It's also possible that clear is a name already used by CrossWorks
somewhere.

When do you get the error?  Is it during compile, link, or debug?

Mike

RE: [lpc2000] Re: C Code Error Help

2006-04-03 by Robert Adsett

At 06:55 PM 4/2/2006 -0600, Michael Anton wrote:
>Well, you really shouldn't try to pass the array.  Usually one would
>pass a pointer to the array.

int x( int y[]);

and

int x( int *y);

are substantially similar.  The first form allows some additional type 
checking and if the following form

int x(int y[3]);

is used then not only is the type checking stronger but some bounds 
checking is also possible.

However, the calling form is the same in all cases, the array degenerates 
to a pointer.  In order to pass an array by value it is necessary to 
encapsulate it in a structure.

Robert


" 'Freedom' has no meaning of itself.  There are always restrictions,   be 
they legal, genetic, or physical.  If you don't believe me, try to chew a 
radio signal. "  -- Kelvin Throop, III
http://www.aeolusdevelopment.com/

RE: [lpc2000] Re: C Code Error Help

2006-04-03 by Robert Adsett

At 07:27 PM 4/2/2006 -0600, Michael Anton wrote:
> > I put static in front of the function call and it will debug now.
> > With my limited knowledge of C I'm not sure why this is the case.  I
> > changed the function call name to ensure that it is an unique
> > without any luck.  Any idea why static works?
>Static limits the scope of the function to the source module it is
>defined in.  I'm not sure why it would fix your problem, other than
>there being another function in a different module or library with
>the same name, but a different prototype.  Alas, with it defined
>as static, you cannot call the function from another module.

It sounds almost like he's got a copy of the function in a header file.

Dewayne,

See if you can reduce the problem to a single file of a few lines.  If the 
problem doesn't become obvious you should have something small enough for 
us to intelligently comment on it.  As it is were making wild stabs in the 
dark.

Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,   be 
they legal, genetic, or physical.  If you don't believe me, try to chew a 
radio signal. "  -- Kelvin Throop, III
http://www.aeolusdevelopment.com/

RE: [lpc2000] Re: C Code Error Help

2006-04-03 by Michael Anton

> -----Original Message-----
> From: lpc2000@yahoogroups.com 
> [mailto:lpc2000@yahoogroups.com]On Behalf
> Of heedaf
> Sent: Sunday, April 02, 2006 6:44 PM
> To: lpc2000@yahoogroups.com
> Subject: [lpc2000] Re: C Code Error Help
> 
>
<snip> 
> I put static in front of the function call and it will debug now.  
> With my limited knowledge of C I'm not sure why this is the case.  I 
> changed the function call name to ensure that it is an unique 
> without any luck.  Any idea why static works?
> Thanks for your help Mike,
> Dewayne
> 
> 

Static limits the scope of the function to the source module it is
defined in.  I'm not sure why it would fix your problem, other than
there being another function in a different module or library with
the same name, but a different prototype.  Alas, with it defined
as static, you cannot call the function from another module.

Mike

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.