2

Code Added:

bool CHARACTER::SpamAllowBuf(const char *Message)
{
    if (!strcmp(Message, "(?˛´c)") || !strcmp(Message, "(μ·)") || !strcmp(Message, "(±a≫Y)") || !strcmp(Message, "(AA??)") || !strcmp(Message, "(≫c¶?)") || !strcmp(Message, "(?đłe)") || !strcmp(Message, "(??C?)") || !strcmp(Message, "(????)") || !strcmp(Message, "(AE??)"))
    {
        return true;
    }

    return false;
}

Warnings Gives :

char.cpp:7254:121: warning: trigraph ??) ignored, use -trigraphs to enable
char.cpp:7254:245: warning: trigraph ??) ignored, use -trigraphs to enable
char.cpp:7254:275: warning: trigraph ??) ignored, use -trigraphs to enable

How can i do to skip this warnings?

Jarod42
  • 203,559
  • 14
  • 181
  • 302

2 Answers2

7

A trigraph sequence is any sequence of characters that starts with "??"; the next character determines the meaning of the sequence. Trigraph sequences are (or were) used to represent characters that weren't provided on some keyboards. So, for example, "??=" means #.

Trigraph sequences aren't widely used any more; I haven't checked, but they may well have been deprecated in C++ or removed entirely. (Thanks to @johnathan for pointing out that they were removed in C++17)

In any event, if you can't turn off that warning, you can change the character sequence so that it looks the same to the compiler but isn't a trigraph. To do that, change one of the ? characters to \?. So "??=" would become "?\?="; that's not a trigraph, because it doesn't consist of the characters "??" followed by another character, but once the compiler has processed it, it's two question marks followed by an '=' sign.

Another way to rearrange the quoted strings is to separate them. So "??=" would become "??" "=" or "?" "?="; the compiler concatenates those adjacent string literals, but, again, they're not trigraphs sequences because the concatenation occurs after checking for trigraphs.

Pete Becker
  • 74,985
  • 8
  • 76
  • 165
  • removed from the standard in c++17. – johnathan Nov 18 '18 at 16:51
  • 2
    @johnathan -- thanks. In practice, they've been removed from compilers for much longer than that. One of the first projects I did for Borland back in the 80s was to write a standalone preprocessor to expand trigraphs, because their C compiler didn't do them. That was pretty common as I recall. – Pete Becker Nov 18 '18 at 16:53
  • 1
    I used "\?" and now compile without warnings ! Thanks – Dutzų Dutzų Nov 18 '18 at 16:58
  • @Pete Becker np. That lingering backward compatibility that confused compilere is finially gone. So you were on the borland team porting to IBM machines? Those were the crux iirc and why trigraphs were even added in the first place. – johnathan Nov 18 '18 at 16:59
  • 1
    @johnathan -- no, just responding to a handful of user complaints; some people actually wanted to use trigraphs. Preprocessing the source file was less invasive than screwing up the scanner. Sometimes politics affects design decisions... – Pete Becker Nov 18 '18 at 17:01
2

To answer your question, use -Wno-trigraphs (if using gcc/clang).

But depending on the version of C++ you are using trigraphs are still part of the standard. Thus express sequences of questions marks like this "?" "?" "?" will avoid hitting the trigraph problem. The compiler will see a string of "???".

Bo R
  • 2,334
  • 1
  • 9
  • 17