NO

Author Topic: Useful warnings  (Read 7023 times)

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Useful warnings
« on: February 10, 2005, 01:48:16 PM »
Pelle,
After a very stressing debug last night I would ask you to add two warnings very useful in some cases (in my case sure  :( ).
I get some misterious code malfunction and I could not detect why nevertheless a lot of debug and time. At last I decided to use another compiler, and  :o that it!
The compiler worned me about a "comment extension on next line", due to a code line follwed by a single line comment ending with a backslash:
Code: [Select]
......................
a = b      //assign variable \
c = d      //this line is NOT CODED!
result = a * c;    //wrong c not assigned yet
.....................

the other warning was referred to #if #endif number mismatch.
Could you please add these two warnings to help to avoid frustrating debugs for a so stupid cases?

Thank-you.
F.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: Useful warnings
« Reply #1 on: February 10, 2005, 06:45:23 PM »
Hello Frankie,

Quote from: "frankie"

The compiler worned me about a "comment extension on next line", due to a code line follwed by a single line comment ending with a backslash:
...

OK - I will try to add a warning about this.

Quote from: "frankie"

the other warning was referred to #if #endif number mismatch.

Can you give me an example? Not sure what you mean...

Pelle
/Pelle

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Useful warnings
« Reply #2 on: February 11, 2005, 09:26:45 AM »
Thank-you Pelle.
The following should be significative
Code: [Select]

/* file.h */
#ifndef __FILE_H_
#define __FILE_H
#define _a 1
#define ........
.....................................
/* end of file.h - the first #ifndef is not closed with a companion #endif */


Regards
F.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Useful warnings
« Reply #3 on: February 11, 2005, 01:24:20 PM »
Mmm... well I do get a level 2 warning for this - "warning #1001: Unterminated conditional in #include."

Pelle
/Pelle

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Useful warnings
« Reply #4 on: February 12, 2005, 01:28:41 PM »
Thank-you very much.
I appreciate.
F.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Useful warnings
« Reply #5 on: March 04, 2005, 09:52:09 AM »
Pelle,
I would precise that on
Quote
Pelles ISO C Compiler, Version 3.00.3 (Beta)

I have no warnings for mismatched #if-#endif.
Regards
F.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Useful warnings
« Reply #6 on: March 04, 2005, 02:00:33 PM »
Quote from: "frankie"
Pelle,
I would precise that on
Quote
Pelles ISO C Compiler, Version 3.00.3 (Beta)

I have no warnings for mismatched #if-#endif.
Regards
F.

Are you setting the compiler warning level to 2 ( /W2 )? Remember that level 1 ( /W1 ) is the default - this will not display level 2 warnings.

If you are, I need a small example. Any way I try it here, it works...

Pelle
/Pelle

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Useful warnings
« Reply #7 on: March 04, 2005, 02:50:28 PM »
Hello Pelle,
You are right I was not using level 2 of warning.
The other compilers that I tried gave the warning without a warning level spec.
I don't know what is the correct handling for this kind of warning, anyway I'll use /W2 next time with POCC.
Thank you for your help.
Regards
F.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide