* On 2021 22 Jan 07:42 -0600, Christoph Berg wrote:
> Re: Nate Bargmann
> > ../../tlf/src/cqww_simulator.c:155:15: warning: adding 'int' to a string 
> > does not append to the string [-Wstring-plus-int]
> >                                     "+++" + 3 - slow);
> >                                     ~~~~~~^~~
> > ../../tlf/src/cqww_simulator.c:155:15: note: use array indexing to silence 
> > this warning
> > 
> > I'm going to be puzzling that one out for a bit.
> 
> As it says, use array indexing: "+++"[3 - slow]

No, the intention is string truncation of 0 to 3 - and + characters
prepending and appending the callsign.

I've attached a short C program that now compiles clean with clang
and gcc with a modification to the format string and the arguments.

73, Nate

-- 

"The optimist proclaims that we live in the best of all
possible worlds.  The pessimist fears this is true."

Web: https://www.n0nb.us
Projects: https://github.com/N0NB
GPG fingerprint: 82D6 4F6B 0E67 CD41 F689 BBA6 FB2C 5130 D55A 8819

#include <glib.h>
#include <glib/gprintf.h>
#include <gmodule.h>


int main(void)
{
	gint32 slow = g_random_int_range(0, 4);

	/* See https://stackoverflow.com/a/16299867 for format explanation. */
	gchar *str = g_strdup_printf("%.*s%s%.*s",
				    3 - slow,
				    "---",  
				    "W0GCJ",
				    3 - slow,
				    "+++");

	g_printf("%s%c", str, '\n');
	g_free(str);
}

Attachment: signature.asc
Description: PGP signature

Reply via email to