qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 19/41] compiler.h: replace QEMU_NORETURN with G_NORETURN


From: Stefan Weil
Subject: Re: [PATCH 19/41] compiler.h: replace QEMU_NORETURN with G_NORETURN
Date: Fri, 7 Apr 2023 19:01:51 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.1

Please excuse the late report, but this old patch causes a build failure for me:

Am 20.04.22 um 15:26 schrieb marcandre.lureau@redhat.com:
From: Marc-André Lureau <marcandre.lureau@redhat.com>

G_NORETURN was introduced in glib 2.68, fallback to G_GNUC_NORETURN in
glib-compat.

Note that this attribute must be placed before the function declaration
(bringing a bit of consistency in qemu codebase usage).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
[...]
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 848916f5165c..14b6b65a5fa9 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -177,7 +177,8 @@ extern "C" {
   * supports QEMU_ERROR, this will be reported at compile time; otherwise
   * this will be reported at link time due to the missing symbol.
   */
-extern void QEMU_NORETURN QEMU_ERROR("code path is reachable")
+extern G_NORETURN
+void QEMU_ERROR("code path is reachable")
      qemu_build_not_reached_always(void);
  #if defined(__OPTIMIZE__) && !defined(__NO_INLINE__)
  #define qemu_build_not_reached()  qemu_build_not_reached_always()

The placement of G_NORETURN causes a compiler error for C++ code in cross builds for Windows (see below). C++ expects the attribute [[noreturn]] before the extern statement.

I updated my Debian build environment to Debian bookworm and a recent cross glib, so maybe the problem was hidden in previous builds because I used a rather old glib or an older g++ cross compiler.

Regards,
Stefan


In file included from /mingw64/lib/glib-2.0/include/glibconfig.h:9,
                 from /mingw64/include/glib-2.0/glib/gtypes.h:34,
                 from /mingw64/include/glib-2.0/glib/galloca.h:34,
                 from /mingw64/include/glib-2.0/glib.h:32,
from /home/stefan/src/qemu/repo.or.cz/qemu/ar7/include/glib-compat.h:32, from /home/stefan/src/qemu/repo.or.cz/qemu/ar7/include/qemu/osdep.h:144,
                 from ../../../qga/vss-win32/requester.cpp:13:
/mingw64/include/glib-2.0/glib/gmacros.h:1076:21: error: standard attributes in middle of decl-specifiers
 1076 | # define G_NORETURN [[noreturn]]
      |                     ^
/home/stefan/src/qemu/repo.or.cz/qemu/ar7/include/qemu/osdep.h:240:8: note: in expansion of macro ‘G_NORETURN’
  240 | extern G_NORETURN
      |        ^~~~~~~~~~
/mingw64/include/glib-2.0/glib/gmacros.h:1076:21: note: standard attributes must precede the decl-specifiers to apply to the declaration, or follow them to apply to the type
 1076 | # define G_NORETURN [[noreturn]]
      |                     ^
/home/stefan/src/qemu/repo.or.cz/qemu/ar7/include/qemu/osdep.h:240:8: note: in expansion of macro ‘G_NORETURN’
  240 | extern G_NORETURN
      |        ^~~~~~~~~~
/mingw64/include/glib-2.0/glib/gmacros.h:1076:21: warning: attribute ignored [-Wattributes]
 1076 | # define G_NORETURN [[noreturn]]
      |                     ^
/home/stefan/src/qemu/repo.or.cz/qemu/ar7/include/qemu/osdep.h:240:8: note: in expansion of macro ‘G_NORETURN’
  240 | extern G_NORETURN
      |        ^~~~~~~~~~
/mingw64/include/glib-2.0/glib/gmacros.h:1076:21: note: an attribute that appertains to a type-specifier is ignored
 1076 | # define G_NORETURN [[noreturn]]
      |                     ^
/home/stefan/src/qemu/repo.or.cz/qemu/ar7/include/qemu/osdep.h:240:8: note: in expansion of macro ‘G_NORETURN’
  240 | extern G_NORETURN
      |        ^~~~~~~~~~
../../../qga/vss-win32/requester.cpp: In function ‘HRESULT requester_init()’: ../../../qga/vss-win32/requester.cpp:72:34: warning: cast between incompatible function types from ‘FARPROC’ {aka ‘long long int (*)()’} to ‘t_CreateVssBackupComponents’ {aka ‘long int (*)(IVssBackupComponents**)’} [-Wcast-function-type]
   72 |     pCreateVssBackupComponents = (t_CreateVssBackupComponents)
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   73 |         GetProcAddress(hLib,
      |         ~~~~~~~~~~~~~~~~~~~~
   74 | #ifdef _WIN64 /* 64bit environment */
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
75 | "?CreateVssBackupComponents@@YAJPEAPEAVIVssBackupComponents@@@Z" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   76 | #else /* 32bit environment */
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
77 | "?CreateVssBackupComponents@@YGJPAPAVIVssBackupComponents@@@Z" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   78 | #endif
      | ~~~~~~
   79 |         );
      |         ~
../../../qga/vss-win32/requester.cpp:85:34: warning: cast between incompatible function types from ‘FARPROC’ {aka ‘long long int (*)()’} to ‘t_VssFreeSnapshotProperties’ {aka ‘void (*)(VSS_SNAPSHOT_PROP*)’} [-Wcast-function-type]
   85 |     pVssFreeSnapshotProperties = (t_VssFreeSnapshotProperties)
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   86 |         GetProcAddress(hLib, "VssFreeSnapshotProperties");
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]