EmbeddedRelated.com
Forums

pragma directives on Codewarrior

Started by cmth2004 January 26, 2004
Erich,
Should this also work (as my manual seems to indicate it should) in V1.2?
I have the following code:
// disable warning about assignment in condition, OK here
#pragma MESSAGE DISABLE C5909
if ((Handles[0] = SML_ListInit( "One", ELEMENTS_8)) < 0)
{
puts("First list init failed\n");
return;
}

but it does not eliminate the warning for C5909.
In fact, I have been unable to change the level to ERROR either.

thanks
ed
--
At 06:05 PM 1/27/2004 +0100, you wrote:
>Hello Chamath,
>Have a look into the compiler manual (#pragma MESSAGE), page 389 of
>Manual_Compiler_HC12.pdf (located in help\pdf).
>
>Syntax:
>"#pragma" "MESSAGE" {("WARNING" | "ERROR" | "INFORMATION" | "DISABLE" |
>"DEFAULT") {<CNUM>}}
>
>Example from there:
>/* treat C1412: Not a function call, */
>/* address of a function, as error */
>#pragma MESSAGE ERROR C1412
>void f(void);
>void main(void) {
>f; /* () is missing, but still legal in C */
>/* ERROR because of pragma MESSAGE */
>}
>
>Erich





Hello Ed,
Yes, it does.
I just verified with following small example:
int i;
void foo(void) {
#pragma MESSAGE DISABLE C5909
if ((i=0) < 0)
{
return;
}
}

Hard to say why it does not on your side. I suggest that you try with above
small example too (just to have a starting point). Maybe there is something
in your project settings I'm not aware of.
If you want, you can send it to me off-list and I will have a look.

Erich

> -----Original Message-----
> From: Ed Carryer [mailto:]
> Sent: Sonntag, 1. Februar 2004 20:54
> To:
> Subject: RE: [68HC12] pragma directives on Codewarrior > Erich,
> Should this also work (as my manual seems to indicate it
> should) in V1.2? I have the following code: // disable
> warning about assignment in condition, OK here #pragma
> MESSAGE DISABLE C5909
> if ((Handles[0] = SML_ListInit( "One", ELEMENTS_8)) < 0)
> {
> puts("First list init failed\n");
> return;
> }
>
> but it does not eliminate the warning for C5909.
> In fact, I have been unable to change the level to ERROR either.
>
> thanks
> ed
> --
> At 06:05 PM 1/27/2004 +0100, you wrote:
> >Hello Chamath,
> >Have a look into the compiler manual (#pragma MESSAGE), page 389 of
> >Manual_Compiler_HC12.pdf (located in help\pdf).
> >
> >Syntax:
> >"#pragma" "MESSAGE" {("WARNING" | "ERROR" | "INFORMATION" |
> "DISABLE" |
> >"DEFAULT") {<CNUM>}}
> >
> >Example from there:
> >/* treat C1412: Not a function call, */
> >/* address of a function, as error */
> >#pragma MESSAGE ERROR C1412
> >void f(void);
> >void main(void) {
> >f; /* () is missing, but still legal in C */
> >/* ERROR because of pragma MESSAGE */
> >}
> >
> >Erich > --------------------To
> learn more about Motorola Microcontrollers, please visit
http://www.motorola.com/mcu o learn more about Motorola Microcontrollers,
please visit http://www.motorola.com/mcu




Hi Erich, Ed,

the #pragma MESSAGE does only apply to full objects, say complete function.
While in Erich's example the message is disabled, it's disabled for the complete function.
Here's a little extract from the pragma message description out of HC12 V3.0's

NOTE This pragma (as other pragmas) has to be specified outside of the
function scope. E.g. it is not possible to change a message inside a
function or for a part of a function.

I'm not sure if this note is also mentioned in the V1.2 version. But it does apply.

So I would suggest that to disable the message, put the pragma outside of the function definition.
And to revert the meaning afterwards do put the opposite pragma after the complete function.

Bye

Daniel > -----Original Message-----
> From: Erich Styger [mailto:]
> Sent: Monday, February 02, 2004 7:22
> To:
> Subject: RE: [68HC12] pragma directives on Codewarrior > Hello Ed,
> Yes, it does.
> I just verified with following small example:
> int i;
> void foo(void) {
> #pragma MESSAGE DISABLE C5909
> if ((i=0) < 0)
> {
> return;
> }
> }
>
> Hard to say why it does not on your side. I suggest that you try with above
> small example too (just to have a starting point). Maybe there is something
> in your project settings I'm not aware of.
> If you want, you can send it to me off-list and I will have a look.
>
> Erich
>
> > -----Original Message-----
> > From: Ed Carryer [mailto:]
> > Sent: Sonntag, 1. Februar 2004 20:54
> > To:
> > Subject: RE: [68HC12] pragma directives on Codewarrior
> >
> >
> > Erich,
> > Should this also work (as my manual seems to indicate it
> > should) in V1.2? I have the following code: // disable
> > warning about assignment in condition, OK here #pragma
> > MESSAGE DISABLE C5909
> > if ((Handles[0] = SML_ListInit( "One", ELEMENTS_8)) < 0)
> > {
> > puts("First list init failed\n");
> > return;
> > }
> >
> > but it does not eliminate the warning for C5909.
> > In fact, I have been unable to change the level to ERROR either.
> >
> > thanks
> > ed
> > --
> > At 06:05 PM 1/27/2004 +0100, you wrote:
> > >Hello Chamath,
> > >Have a look into the compiler manual (#pragma MESSAGE), page 389 of
> > >Manual_Compiler_HC12.pdf (located in help\pdf).
> > >
> > >Syntax:
> > >"#pragma" "MESSAGE" {("WARNING" | "ERROR" | "INFORMATION" |
> > "DISABLE" |
> > >"DEFAULT") {<CNUM>}}
> > >
> > >Example from there:
> > >/* treat C1412: Not a function call, */
> > >/* address of a function, as error */
> > >#pragma MESSAGE ERROR C1412
> > >void f(void);
> > >void main(void) {
> > >f; /* () is missing, but still legal in C */
> > >/* ERROR because of pragma MESSAGE */
> > >}
> > >
> > >Erich
> >

>