EmbeddedRelated.com
Forums

Crossworks beginner

Started by normnet2003 February 17, 2011
I'm not able to correct the error "invalid use of void expression".

My background is in Basic and PIC but I have successfully ported several basic PIC programs to C PIC.
Now I am trying ARM but cannot correct this simple error.
The Crossworks tutorial states "To correct the error, change the return type of factorial from void to int in its prototype."

// CrossWorks Tutorial

#include

void factorial(int);

int main(void)
{
int i;
for (i = 0; i < 10; ++i)
debug_printf("Factorial of %d is %d\n", i, factorial(i)); //this line: invalid use of void expression
return 0;
}

Norm

An Engineer's Guide to the LPC2100 Series

Am 17.02.2011 08:52, schrieb normnet2003:
> I'm not able to correct the error "invalid use of void expression".
>
> My background is in Basic and PIC but I have successfully ported several basic PIC programs to C PIC.
> Now I am trying ARM but cannot correct this simple error.

Then you should go an buy a book on C and _read_ it. Then go back to the
tutorial.

> The Crossworks tutorial states "To correct the error, change the return type of factorial from void to int in its prototype."

Did you really read above line ?

--
42Bastian
+
| http://www.sciopta.com
| Fastest direct message passing kernel.
| IEC61508 certified.
+
Hello,

easy thing, not Crossworks related at all, basic C knowledge.

void factorial(int);

means the function factorial return nothing (!).

But with your debug_printf you print out the return value
of factorial.

Try something like

int factorial(int);

Best regards,

Martin

--- In l..., "normnet2003" wrote:
>
> I'm not able to correct the error "invalid use of void expression".
>
> My background is in Basic and PIC but I have successfully ported several basic PIC programs to C PIC.
> Now I am trying ARM but cannot correct this simple error.
> The Crossworks tutorial states "To correct the error, change the return type of factorial from void to int in its prototype."
>
> // CrossWorks Tutorial
>
> #include void factorial(int);
>
> int main(void)
> {
> int i;
> for (i = 0; i < 10; ++i)
> debug_printf("Factorial of %d is %d\n", i, factorial(i)); //this line: invalid use of void expression
> return 0;
> }
>
> Norm
>

On 17/02/2011 07:52, normnet2003 wrote:
> I'm not able to correct the error "invalid use of void expression".
>
> My background is in Basic and PIC but I have successfully ported several basic PIC programs to C PIC.
> Now I am trying ARM but cannot correct this simple error.
> The Crossworks tutorial states "To correct the error, change the return type of factorial from void to int in its prototype."
Buy a copy of The C Programming Language by Kernighan and Ritchie. All
wiil be explained!

Leon
--
Leon Heller
G1HSM
well recommended, a book that will not leave you for rest of your life....

________________________________
From: Leon Heller
To: l...
Sent: Thu, February 17, 2011 3:55:56 AM
Subject: Re: [lpc2000] Crossworks beginner

On 17/02/2011 07:52, normnet2003 wrote:
> I'm not able to correct the error "invalid use of void expression".
>
> My background is in Basic and PIC but I have successfully ported several basic
>PIC programs to C PIC.
> Now I am trying ARM but cannot correct this simple error.
> The Crossworks tutorial states "To correct the error, change the return type of
>factorial from void to int in its prototype."

Buy a copy of The C Programming Language by Kernighan and Ritchie. All
wiil be explained!

Leon
--
Leon Heller
G1HSM
int factorial(int); was tried but no luck.

Norm
--- In l..., "capiman26061973" wrote:
>
> Hello,
>
> easy thing, not Crossworks related at all, basic C knowledge.
>
> void factorial(int);
>
> means the function factorial return nothing (!).
>
> But with your debug_printf you print out the return value
> of factorial.
>
> Try something like
>
> int factorial(int);
>
> Best regards,
>
> Martin
>
> --- In l..., "normnet2003" wrote:
> >
> > I'm not able to correct the error "invalid use of void expression".
> >
> > My background is in Basic and PIC but I have successfully ported several basic PIC programs to C PIC.
> > Now I am trying ARM but cannot correct this simple error.
> > The Crossworks tutorial states "To correct the error, change the return type of factorial from void to int in its prototype."
> >
> > // CrossWorks Tutorial
> >
> > #include
> >
> > void factorial(int);
> >
> > int main(void)
> > {
> > int i;
> > for (i = 0; i < 10; ++i)
> > debug_printf("Factorial of %d is %d\n", i, factorial(i)); //this line: invalid use of void expression
> > return 0;
> > }
> >
> > Norm
>

Hi,

> int factorial(int); was tried but no luck.

The CrossWorks tutorial is designed to take you through fixing problems
using CrossWorks; once you fix this up, there are more things to fix up,
that's the way it's designed.

If you can't work through the tutorial, you need to go back to basics and
find a book on C, like this one:



Guy Steele is a man with a great pedigree.

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
SolderCore arriving Summer 2011! http://www.soldercore.com

On 17/02/2011 13:22, normnet2003 wrote:
>
>
> int factorial(int); was tried but no luck.

Apologies up front if this is a daft question - but did change the
function definition as well as the prototype?

Regards,
Richard.

+ http://www.FreeRTOS.org
Designed for Microcontrollers.
150,000 Downloads in Two Years.

>
> Norm
>
> --- In l... ,
> "capiman26061973" wrote:
>>
>> Hello,
>>
>> easy thing, not Crossworks related at all, basic C knowledge.
>>
>> void factorial(int);
>>
>> means the function factorial return nothing (!).
>>
>> But with your debug_printf you print out the return value
>> of factorial.
>>
>> Try something like
>>
>> int factorial(int);
>>
>> Best regards,
>>
>> Martin
>>
>> --- In l... ,
> "normnet2003" wrote:
>> >
>> > I'm not able to correct the error "invalid use of void expression".
>> >
>> > My background is in Basic and PIC but I have successfully ported
> several basic PIC programs to C PIC.
>> > Now I am trying ARM but cannot correct this simple error.
>> > The Crossworks tutorial states "To correct the error, change the
> return type of factorial from void to int in its prototype."
>> >
>> > // CrossWorks Tutorial
>> >
>> > #include
>> >
>> > void factorial(int);
>> >
>> > int main(void)
>> > {
>> > int i;
>> > for (i = 0; i < 10; ++i)
>> > debug_printf("Factorial of %d is %d\n", i, factorial(i)); //this
> line: invalid use of void expression
>> > return 0;
>> > }
>> >
>> > Norm
>> >
>>

Hi Richard,

> On 17/02/2011 13:22, normnet2003 wrote:
> >
> >
> > int factorial(int); was tried but no luck.
>
> Apologies up front if this is a daft question - but did change the
> function definition as well as the prototype?

...the tutorial carries on with more things to fix up, so one assumes that
the tutorial hasn't been followed...

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
SolderCore arriving Summer 2011! http://www.soldercore.com

On Thu, Feb 17, 2011 at 10:22 AM, normnet2003 wrote:

> int factorial(int); was tried but no luck.
>

Norm,

Did you try defining the factorial function somewhere?

I mean, not just declare "int factorial(int);" but also telling the
compiler what a factorial is supposed to do... Some research guys have been
trying to implement a crystal ball into the language but they are not quite
there yet... :-)

Cheers
--
Olivier Gautherot
o...@gautherot.net

>
> Norm
>
> --- In l..., "capiman26061973"
> wrote:
> >
> > Hello,
> >
> > easy thing, not Crossworks related at all, basic C knowledge.
> >
> > void factorial(int);
> >
> > means the function factorial return nothing (!).
> >
> > But with your debug_printf you print out the return value
> > of factorial.
> >
> > Try something like
> >
> > int factorial(int);
> >
> > Best regards,
> >
> > Martin
> >
> > --- In l..., "normnet2003" wrote:
> > >
> > > I'm not able to correct the error "invalid use of void expression".
> > >
> > > My background is in Basic and PIC but I have successfully ported
> several basic PIC programs to C PIC.
> > > Now I am trying ARM but cannot correct this simple error.
> > > The Crossworks tutorial states "To correct the error, change the return
> type of factorial from void to int in its prototype."
> > >
> > > // CrossWorks Tutorial
> > >
> > > #include
> > >
> > > void factorial(int);
> > >
> > > int main(void)
> > > {
> > > int i;
> > > for (i = 0; i < 10; ++i)
> > > debug_printf("Factorial of %d is %d\n", i, factorial(i)); //this line:
> invalid use of void expression
> > > return 0;
> > > }
> > >
> > > Norm
> > >
> >
>