Sign in

username:

password:



Not a member?

Search 68hc12



Search tips

Subscribe to 68hc12



68hc12 by Keywords

68HC1 | 812A4 | 9S12DP256 | Bootloader | CodeWarrior | D60A | Debugger | DP256 | ECT | EEPROM | EVB | Flash | HC1 | HCS12 | I2C | IAR | ICC1 | Interrupts | LCD | M68KIT912DP256 | MC9S12DP256 | MC9S12DP256B | Metrowerks | Motor | MSCAN | Multilink | PLL | Quadrature | SDI | SPI | Transceiver | XFC

Ads

Discussion Groups

Discussion Groups | 68HC12 | Re: CodeWarrior bugs

Join our technical discussions about Freescale Microcontrollers: M68HC12. (Freescale Semiconductor is a Subsidiary of Motorola).

CodeWarrior bugs - Thiago A. Corrêa - Apr 18 18:47:00 2005

Hi,

I'm having some quite anoying problems with codewarrior bugs,
related to the lack of code checking by the compiler mostly.

First I had a function that was declared in the header with a
missing argument, but implemented and called with the *extra* argument
( implementation and call in different translation units, but both
including the bogus header ). CW compiled fine, and running on the
hardware *sort* of worked, it did the call, but the params was messed
up. Figured out the header and fixed it. No compiler warning to hint
me, no linking errors saying there wasn't a match for the call. Then
again, I have another call that has the right number of params but one
of their values get in wrong... like mycall( 1, 0, 0 ) and it thinks
the first param is 0!

Am I the only one having this sort of problems with CW? I can't
belive that I found such silly bugs in my first week using it *g*.

Thanks,
Thiago A. Corrêa





(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )


RE: CodeWarrior bugs - Erich Styger - Apr 19 8:06:00 2005

Hi Thiago,
There are probably several reasons:
- you switched off warnings (check if you have -W2 in your command line)
- for your case below (declaring numbers of arguments, but using more in the
call),
you will get a compiler error: ERROR C1821: Wrong number of arguments
So it could be that you did not let the compiler see the declaration?
Maybe you
missed to include the header file? So you have an implicit parameter
declaration
(the compiler warns you about this as well)
- for implicit parameter declaration there is an option -Wpd which flags
this as
error: try it if this is your problem.
- your last problem about order of arguments: this may be one of the above
things. Otherwise
you have to know that for open argument lists (...) the order of arguments
is different too for the compiler.
So here again you have to match the declaration with the implementation in
your sources.

All things above are not a compiler bug: it is more one of the traps and
pitfalls of the C language.

Otherwise I would need a better description/example: contact me either
off-list or contact support@supp... and they could help you out.

Thanks,
Erich

> -----Original Message-----
> From: 68HC12@68HC... [mailto:68HC12@68HC...]
> On Behalf Of Thiago A. Corrêa
> Sent: Montag, 18. April 2005 17:47
> To: 68HC12@68HC...
> Subject: [68HC12] CodeWarrior bugs >
> Hi,
>
> I'm having some quite anoying problems with codewarrior bugs,
> related to the lack of code checking by the compiler mostly.
>
> First I had a function that was declared in the header with a
> missing argument, but implemented and called with the *extra* argument
> ( implementation and call in different translation units, but both
> including the bogus header ). CW compiled fine, and running on the
> hardware *sort* of worked, it did the call, but the params was messed
> up. Figured out the header and fixed it. No compiler warning to hint
> me, no linking errors saying there wasn't a match for the call. Then
> again, I have another call that has the right number of params but one
> of their values get in wrong... like mycall( 1, 0, 0 ) and it thinks
> the first param is 0!
>
> Am I the only one having this sort of problems with CW? I can't
> belive that I found such silly bugs in my first week using it *g*.
>
> Thanks,
> Thiago A. Corrêa >
> Yahoo! Groups Links





(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: CodeWarrior bugs - Thiago A. Corrêa - Apr 20 10:52:00 2005

Hi, thanks for the reply. Some observations did help pinpoint the
problem, but still I´m not sure if the compiler is doing the right
thing. I don´t know ANSI C, but I do like to think that I know ANSI
C++ very well, and in that case it should give by default errors since
it generates wrong code. But then again, this is C code...

No implicit parameters or elipsis calls, simple call with constants in
the call! The thing is that the include where it was foward declared
was missing in the translation unit, after adding it, worked fine.
*sigh*.

Regards,
Thiago A. Corrêa

On 4/19/05, Erich Styger <erich.styger@eric...> wrote:
> Hi Thiago,
> There are probably several reasons:
> - you switched off warnings (check if you have -W2 in your command line)
> - for your case below (declaring numbers of arguments, but using more in
> the
> call),
> you will get a compiler error: ERROR C1821: Wrong number of arguments
> So it could be that you did not let the compiler see the declaration?
> Maybe you
> missed to include the header file? So you have an implicit parameter
> declaration
> (the compiler warns you about this as well)
> - for implicit parameter declaration there is an option -Wpd which flags
> this as
> error: try it if this is your problem.
> - your last problem about order of arguments: this may be one of the above
> things. Otherwise
> you have to know that for open argument lists (...) the order of
> arguments
> is different too for the compiler.
> So here again you have to match the declaration with the implementation
> in
> your sources.
>
> All things above are not a compiler bug: it is more one of the traps and
> pitfalls of the C language.
>
> Otherwise I would need a better description/example: contact me either
> off-list or contact support@supp... and they could help you out.
>
> Thanks,
> Erich > > -----Original Message-----
> > From: 68HC12@68HC... [mailto:68HC12@68HC...]
> > On Behalf Of Thiago A. Corrêa
> > Sent: Montag, 18. April 2005 17:47
> > To: 68HC12@68HC...
> > Subject: [68HC12] CodeWarrior bugs
> >
> >
> >
> > Hi,
> >
> > I'm having some quite anoying problems with codewarrior bugs,
> > related to the lack of code checking by the compiler mostly.
> >
> > First I had a function that was declared in the header with a
> > missing argument, but implemented and called with the *extra* argument
> > ( implementation and call in different translation units, but both
> > including the bogus header ). CW compiled fine, and running on the
> > hardware *sort* of worked, it did the call, but the params was messed
> > up. Figured out the header and fixed it. No compiler warning to hint
> > me, no linking errors saying there wasn't a match for the call. Then
> > again, I have another call that has the right number of params but one
> > of their values get in wrong... like mycall( 1, 0, 0 ) and it thinks
> > the first param is 0!
> >
> > Am I the only one having this sort of problems with CW? I can't
> > belive that I found such silly bugs in my first week using it *g*.
> >
> > Thanks,
> > Thiago A. Corrêa
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> > ________________________________
> Yahoo! Groups Links > To





(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: CodeWarrior bugs - MW Ron - Apr 20 11:01:00 2005

Thiago A. Corrêa wrote:

> Hi, thanks for the reply. Some observations did help pinpoint the
> problem, but still I´m not sure if the compiler is doing the right
> thing. I don´t know ANSI C, but I do like to think that I know ANSI
> C++ very well, and in that case it should give by default errors since
> it generates wrong code. But then again, this is C code...
>
> No implicit parameters or elipsis calls, simple call with constants in
> the call! The thing is that the include where it was foward declared
> was missing in the translation unit, after adding it, worked fine.
> *sigh*.

Unlike C++ the standard C does not require prototypes. If they are missing
then you will have these problems that you are seeing. I believe that
CodeWarrior has an option to require prototypes for C, and I always
recommend it be on, right now I don't have the HC12 tools so I can verify
this option, but I'm hope someone will.

C has roots in K&R which did not use prototypes and that is part of the
problem. Also prior to C99 (probably another option) if an implicit int was
assumed as return value.

Ron
--
Metrowerks Community Forum is a free online resource for developers
to discuss CodeWarrior topics with other users and Metrowerks' staff
-- http://www.metrowerks.com/community --

Ron Liechty - MWRon@MWRo... - http://www.metrowerks.com




(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

RE: CodeWarrior bugs - Erich Styger - Apr 20 11:11:00 2005

Hi Thiago,
Glad that the problem is sorted out.
ANSI-C is really not catching things like the one below (for legacy reason),
that's why most compiler add options like the -Wpd below to catch things
like this.

On the other side: C++ provides a lot of this things in the language itself,
so I see good reasons to compile your normal C code as C++, as the compiler
can flag more problems automatically. Moreover, due the name encoding,
things like this can be catched in the linker too.
Just a thought.

Erich

> -----Original Message-----
> From: 68HC12@68HC... [mailto:68HC12@68HC...]
> On Behalf Of Thiago A. Corrêa
> Sent: Mittwoch, 20. April 2005 09:52
> To: 68HC12@68HC...
> Subject: Re: [68HC12] CodeWarrior bugs >
> Hi, thanks for the reply. Some observations did help pinpoint the
> problem, but still I´m not sure if the compiler is doing the right
> thing. I don´t know ANSI C, but I do like to think that I know ANSI
> C++ very well, and in that case it should give by default errors since
> it generates wrong code. But then again, this is C code...
>
> No implicit parameters or elipsis calls, simple call with constants in
> the call! The thing is that the include where it was foward declared
> was missing in the translation unit, after adding it, worked fine.
> *sigh*.
>
> Regards,
> Thiago A. Corrêa
>
> On 4/19/05, Erich Styger <erich.styger@eric...> wrote:
> > Hi Thiago,
> > There are probably several reasons:
> > - you switched off warnings (check if you have -W2 in your
> command line)
> > - for your case below (declaring numbers of arguments, but
> using more in
> > the
> > call),
> > you will get a compiler error: ERROR C1821: Wrong number
> of arguments
> > So it could be that you did not let the compiler see the
> declaration?
> > Maybe you
> > missed to include the header file? So you have an
> implicit parameter
> > declaration
> > (the compiler warns you about this as well)
> > - for implicit parameter declaration there is an option
> -Wpd which flags
> > this as
> > error: try it if this is your problem.
> > - your last problem about order of arguments: this may be
> one of the above
> > things. Otherwise
> > you have to know that for open argument lists (...) the order of
> > arguments
> > is different too for the compiler.
> > So here again you have to match the declaration with the
> implementation
> > in
> > your sources.
> >
> > All things above are not a compiler bug: it is more one of
> the traps and
> > pitfalls of the C language.
> >
> > Otherwise I would need a better description/example:
> contact me either
> > off-list or contact support@supp... and they could
> help you out.
> >
> > Thanks,
> > Erich
> >
> >
> > > -----Original Message-----
> > > From: 68HC12@68HC... [mailto:68HC12@68HC...]
> > > On Behalf Of Thiago A. Corrêa
> > > Sent: Montag, 18. April 2005 17:47
> > > To: 68HC12@68HC...
> > > Subject: [68HC12] CodeWarrior bugs
> > >
> > >
> > >
> > > Hi,
> > >
> > > I'm having some quite anoying problems with codewarrior bugs,
> > > related to the lack of code checking by the compiler mostly.
> > >
> > > First I had a function that was declared in the header with a
> > > missing argument, but implemented and called with the
> *extra* argument
> > > ( implementation and call in different translation
> units, but both
> > > including the bogus header ). CW compiled fine, and
> running on the
> > > hardware *sort* of worked, it did the call, but the
> params was messed
> > > up. Figured out the header and fixed it. No compiler
> warning to hint
> > > me, no linking errors saying there wasn't a match for
> the call. Then
> > > again, I have another call that has the right number of
> params but one
> > > of their values get in wrong... like mycall( 1, 0, 0 )
> and it thinks
> > > the first param is 0!
> > >
> > > Am I the only one having this sort of problems with CW? I can't
> > > belive that I found such silly bugs in my first week
> using it *g*.
> > >
> > > Thanks,
> > > Thiago A. Corrêa
> > >
> > >
> > >
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> > ________________________________
> > Yahoo! Groups Links
> >
> >
> > To >
> Yahoo! Groups Links





(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: CodeWarrior bugs - William R. Elliot - Apr 20 11:15:00 2005

In version CW version 2.1, the message C1801 flags the call to a function
without a prototype. Make sure this message is active in the compiler
settings.

Bill >Thiago A. Corrêa wrote:
>
> > Hi, thanks for the reply. Some observations did help pinpoint the
> > problem, but still I´m not sure if the compiler is doing the right
> > thing. I don´t know ANSI C, but I do like to think that I know ANSI
> > C++ very well, and in that case it should give by default errors since
> > it generates wrong code. But then again, this is C code...
> >
> > No implicit parameters or elipsis calls, simple call with constants in
> > the call! The thing is that the include where it was foward declared
> > was missing in the translation unit, after adding it, worked fine.
> > *sigh*.
>
>Unlike C++ the standard C does not require prototypes. If they are missing
>then you will have these problems that you are seeing. I believe that
>CodeWarrior has an option to require prototypes for C, and I always
>recommend it be on, right now I don't have the HC12 tools so I can verify
>this option, but I'm hope someone will.
>
>C has roots in K&R which did not use prototypes and that is part of the
>problem. Also prior to C99 (probably another option) if an implicit int was
>assumed as return value.
>
>Ron




(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: CodeWarrior bugs - Oliver Betz - Apr 20 11:48:00 2005

Thiago A. Corrêa <thiago.correa@thia...> wrote:

> Hi, thanks for the reply. Some observations did help pinpoint the
> problem, but still I´m not sure if the compiler is doing the right
> thing. I don´t know ANSI C, but I do like to think that I know ANSI
> C++ very well, and in that case it should give by default errors since

if you "know ANSI C++ very well", you also should also know and use
some flavour of Lint (I recommend PC-Lint for embedded stuff).

"Lint early, lint often. Lint is your friend."

At least lint before you wonder why something doesn't work.

Oliver
--
Oliver Betz, Muenchen




(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )