Pelles C forum

Pelles C => General discussions => Topic started by: John Z on April 16, 2022, 12:54:28 PM

Title: Compiler warning on comment?
Post by: John Z 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
Title: Re: Compiler warning on comment?
Post by: frankie 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.
Title: Re: Compiler warning on comment?
Post by: John Z 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

Title: Re: Compiler warning on comment?
Post by: frankie on April 16, 2022, 07:28:38 PM
Anyway I have to admit that the warning is very annoying!  >:(  ;D ;D
Title: Re: Compiler warning on comment?
Post by: Grincheux 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
??=#
??([
??/\
??)]
??'^
??<{
??!|
??>}
??-~