mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-10-31 00:12:19 +01:00 
			
		
		
		
	build: avoid "-Werror=format-extra-args" warnings in detecting printf for gnulib
Otherwise, `CFLAGS='-Wall -Werror' meson build` fails detection with:
  Running compile:
  Working directory:  /data/src/glib/build/meson-private/tmpoozk2y4b
  Code:
  #include <stdio.h>
  #include <string.h>
  static char buf[100];
  static double zero = 0.0;
  int main ()
  {
    if (sprintf (buf, "%010f", 1.0 / zero, 33, 44, 55) < 0
        || (strcmp (buf, "       inf") != 0
            && strcmp (buf, "  infinity") != 0))
      return 1;
    return 0;
  }
  -----------
  Command line: `cc /data/src/glib/build/meson-private/tmpoozk2y4b/testfile.c -o /data/src/glib/build/meson-private/tmpoozk2y4b/output.exe -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1
  stderr:
  /data/src/glib/build/meson-private/tmpoozk2y4b/testfile.c: In function 'main':
  /data/src/glib/build/meson-private/tmpoozk2y4b/testfile.c:8:21: error: too many arguments for format [-Werror=format-extra-args]
      8 |   if (sprintf (buf, "%010f", 1.0 / zero, 33, 44, 55) < 0
        |                     ^~~~~~~
  cc1: all warnings being treated as errors
  -----------
  Could not compile test file /data/src/glib/build/meson-private/tmpoozk2y4b/testfile.c: 1
  Checking if "printf supports the zero flag correctly" runs: DID NOT COMPILE
			
			
This commit is contained in:
		| @@ -15,7 +15,7 @@ static double zero = 0.0; | ||||
| int main () | ||||
| { | ||||
|   int result = 0; | ||||
|   if (sprintf (buf, "%F %d", 1234567.0, 33, 44, 55) < 0 | ||||
|   if (sprintf (buf, "%F %d", 1234567.0, 33) < 0 | ||||
|       || strcmp (buf, "1234567.000000 33") != 0) | ||||
|     result |= 1; | ||||
|   if (sprintf (buf, "%F", 1.0 / zero) < 0 | ||||
|   | ||||
| @@ -15,7 +15,7 @@ static char buf[100]; | ||||
| static double zero = 0.0; | ||||
| int main () | ||||
| { | ||||
|   if (sprintf (buf, "%010f", 1.0 / zero, 33, 44, 55) < 0 | ||||
|   if (sprintf (buf, "%010f", 1.0 / zero) < 0 | ||||
|       || (strcmp (buf, "       inf") != 0 | ||||
|           && strcmp (buf, "  infinity") != 0)) | ||||
|     return 1; | ||||
|   | ||||
| @@ -15,15 +15,15 @@ int main () | ||||
| { | ||||
|   int result = 0; | ||||
|   buf[0] = '\0'; | ||||
|   if (sprintf (buf, "%Lf %d", 1.75L, 33, 44, 55) < 0 | ||||
|   if (sprintf (buf, "%Lf %d", 1.75L, 33) < 0 | ||||
|       || strcmp (buf, "1.750000 33") != 0) | ||||
|     result |= 1; | ||||
|   buf[0] = '\0'; | ||||
|   if (sprintf (buf, "%Le %d", 1.75L, 33, 44, 55) < 0 | ||||
|   if (sprintf (buf, "%Le %d", 1.75L, 33) < 0 | ||||
|       || strcmp (buf, "1.750000e+00 33") != 0) | ||||
|     result |= 2; | ||||
|   buf[0] = '\0'; | ||||
|   if (sprintf (buf, "%Lg %d", 1.75L, 33, 44, 55) < 0 | ||||
|   if (sprintf (buf, "%Lg %d", 1.75L, 33) < 0 | ||||
|       || strcmp (buf, "1.75 33") != 0) | ||||
|     result |= 4; | ||||
|   return result; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user