NO

Author Topic: Incorrect warning #1004  (Read 2603 times)

JFG

  • Guest
Incorrect warning #1004
« on: April 16, 2009, 09:49:46 PM »
Hello,

the following code:

Code: [Select]
   #ifndef __POCC__
      #unrecognized pp directive
   #endif

causes the compiler to raises a "warning #1004: Unknown preprocessor control: 'unrecognized'.", even if there is a line like:

Code: [Select]
   #pragma warn (disable 1004)

to avoid it.

Souldn't it ignore the line in the #ifndef __POCC__ / #endif block? Or at least, can the #pragma directive disable efectively the warning?

I need it in order to guard code for other (not C) compiler.

TIA,

Jose F. Gimenez

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: Incorrect warning #1004
« Reply #1 on: April 21, 2009, 02:03:25 PM »
The preprocessor currently has no support/understanding of #pragma's, it only passes them on to the "real" C compiler (which compiles the preprocessed source code). If the "real" C compiler happens to see the #pragma warn ... before the preprocess finds a line to complain about, the preprocessor can make use of the disabled warning info. The "real" compiler reads preprocessed code in large blocks, for efficiency, so it's not line-by-line oriented. In other words: it may or may not work to disable warnings in the preprocessor.

This is obviously not prefect. Making a satisfactory change for this will take several weeks, and I was hoping to release a new version soon-ish. I don't have all the time in the world to work on Pelles C right now, so this may push the release forward a few month. I have to think about this...

Edit:
The C99 standard says: "When in a group that is skipped, the directive syntax is relaxed to allow any sequence of preprocessing tokens to occur between the directive name and the following new-line character." - my interpretation is that the directive name needs to be recognized, and "unrecognized" isn't, so the warning should be OK (but I need to check some more).
« Last Edit: April 21, 2009, 04:28:29 PM by Pelle »
/Pelle

JFG

  • Guest
Re: Incorrect warning #1004
« Reply #2 on: April 22, 2009, 10:45:27 AM »
Pelle,

thanks for answer.

I'm not an expert at all in C99 standards nor in C compiler internals, but I've used that syntax construction many times before with other C compilers (BCC++ and MinGW) and didn't cause any warning message. I hope you to take it into account.

I'm evaluating Pelles C and I'm very impressed. It's a very good solution for C programming.

Thanks again.

Jose F. Gimenez

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: Incorrect warning #1004
« Reply #3 on: April 23, 2009, 03:08:20 PM »
I have seen some C compilers issuing a warning here, and others that don't. In the end the C standard should give the answer, I guess. Even when skipping, the preprocessor needs to look for #endif at least, and if you have misspelled endif a warning may be helpful (for some implementations).

Anyway, what I have done is to let the preprocessor "peek" at #pragma warn with enable or disable (and the numeric range for preprocessor warnings), and handle that in the preprocessor (everything is then passed on). The illusion should be that you can now enable or disable warnings in the preprocessor. The push and pop form of #pragma warn is not handled by the preprocessor, but this should be less of a problem.
/Pelle