NO

Author Topic: Compiler warning on comment?  (Read 4096 times)

Offline John Z

  • Member
  • *
  • Posts: 860
Compiler warning on comment?
« on: April 16, 2022, 12:54:28 PM »
Here is one to consider:
I get this warning on compile in Pelles version 10 ... yes I know upgrade soon!  :)
-
C:\Program Files\PellesC\Files\vCardz\vCardz\search.c(1006): warning #1044: Trigraph '??!' converted to '|'.


due to this source line
Code: [Select]
             { startrec = 0;} // back to the start (what about loop when doing directory??!!)
I would not think the compiler would care what is in a comment... even though Level 2 and C11

Smallest program is not included since you can just paste the comment.  BUT if that doesn't work I'll post.

John Z

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Compiler warning on comment?
« Reply #1 on: April 16, 2022, 04:29:55 PM »
Hello John,
this behavior is fully compliant with the standard, apart the warning that is just informational to advice you that a trigraph has been found and translated.
The C standards, from C89 up to C20, specify the the first phase of a 'unit translation' (read source file compilation), is the mapping of source file to source character set and the translations of trigraphs.
From C17 standard draft:
Quote
5.1.1.2 Translation phases
.1 The precedence among the syntax rules of translation is specified by the following phases.
    1. Physical source file multibyte characters are mapped, in an implementation-defined manner, to
        the source character set (introducing new-line characters for end-of-line indicators) if necessary.
       Trigraph sequences are replaced by corresponding single-character internal representations.
    2. Each instance of a backslash character (\) immediately followed by a new-line character is
        deleted, splicing physical source lines (... omissis ...)
So in the very first phase trigraphs are translated to the internal representation, and a warning showed for each of them. This happens before the comment is stripped out from translation process.
« Last Edit: April 16, 2022, 04:32:31 PM by frankie »
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Offline John Z

  • Member
  • *
  • Posts: 860
Re: Compiler warning on comment?
« Reply #2 on: April 16, 2022, 05:51:42 PM »
Thanks for the great explanation, especially the
This happens before the comment is stripped out from translation process

Got it!

Thank you,
John Z


Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Compiler warning on comment?
« Reply #3 on: April 16, 2022, 07:28:38 PM »
Anyway I have to admit that the warning is very annoying!  >:(  ;D ;D
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Grincheux

  • Guest
Re: Compiler warning on comment?
« Reply #4 on: April 20, 2022, 12:13:44 PM »
From Pelle's help file:


Quote
C trigraph sequences 
All occurrences in a source file of the following sequences of three characters (called trigraph sequences) are replaced with the corresponding single character. They are meant for computers with limited character sets.
 
 
TrigraphCharacter
??=#
??([
??/\
??)]
??'^
??<{
??!|
??>}
??-~
« Last Edit: May 29, 2022, 09:09:22 AM by Stefan Pendl »