Getting rid of the " Deprecated ... \<newline><white>*. Use \c" warning

I’m using: SWI-Prolog version
Welcome to SWI-Prolog (threaded, 32 bits, version 7.4.2) (windowS)

I want the code to:

not to warn about strings such as the example not to give any warning.

My code looks like this:

% your code here

mypredicate( "this is a string \
and I'd like to keep adding new lines \
with no warning")

As I don’t know how you created the warning and I can not reproduce it to check this,

the change you need to make should be as simple as using \c where you are using \.

e.g.

mypredicate( "\c
    this is a string \c
    and I'd like to keep adding new lines \c
    with no warning").

But I want to keep terminating the lines with \ instead of “\c” since other prolog dialects do so, and I can change from one program to another easily.
If I migrate large chunks then suddenly I got a lot of warnings.

You should be able to intercept the warning message and suppress it using the message_hook/3 hook predicate. Something like (not tested):

:- multifile(user:message_hook/3).
message_hook(syntax_error(swi_backslash_newline), _, _).

Another possible option can be found in the documentation: Character Escape Syntax

\<NEWLINE>

When in ISO mode (see the Prolog flag iso), only skip this sequence. In native mode, white space that follows the newline is skipped as well and a warning is printed, indicating that this construct is deprecated and advising to use \c . We advise using \c or putting the layout before the \ , as shown below. Using \c is supported by various other Prolog implementations and will remain supported by SWI-Prolog. The style shown below is the most compatible solution.

As suggested, try using ISO mode via the iso flag

It hasn’t worked, it keeps warning.

But, in a file I can’t set
set_prolog_flag(iso,true).
since it says I’m redefining the predicate.
It works for the “user” debugging(sending prolog code to a prolog process in an emacs windowS), which is great.

After digging a bit more, this works using your sample code for testing:

:- multifile(user:message_hook/3).
message_hook(error(syntax_error(swi_backslash_newline),_), warning, _).

whoooo! That is . Many thanks!

set_prolog_flag/2 is both a built-in predicate and a directive. In a file, you would write:

:- set_prolog_flag(iso ,true).

But, if you read the documentation on this flag, you will see that it have other consequences that you may or may not want.

I missed that It was a directive, also.

That is a bit old. As @EricGT says, this doesn’t replicate. Current versions only give this warning if the next line starts with a blank.