Skip to contentSkip to conversation

qga/vss-win32: fix compilation with clang++

PATCH-for-7.0 Helge Konetzka 3 participants 3 messages Mar 16, 2022

lore
Share & tools
lore
#0 lore raw

Compiling with clang++ of msys2 toolchain clang64 leads to an error on initializing 'char*' variable nul with a 'const char*' value

---
Compiling with clang++ of msys2 toolchain clang64 leads to

[1445/1747] Compiling C++ object qga/vss-win32/qga-vss.dll.p/install.cpp.obj
FAILED: qga/vss-win32/qga-vss.dll.p/install.cpp.obj
...
qga/vss-win32/install.cpp:49:24: error: cannot initialize a variable of type 'char *' with an rvalue of type 'const char *'

    char *msg = NULL, *nul = strchr(text, '(');
                       ^     ~~~~~~~~~~~~~~~~~

1 error generated.
ninja: build stopped: subcommand failed.
make: *** [Makefile:163: run-ninja] Error 1
==> ERROR: A failure occurred in build().

    Aborting...
---
 qga/vss-win32/install.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
qga/vss-win32/install.cpp +2 -1
index 8076efe3cb..b57508fbe0 100644
@@ -46,7 +46,8 @@ void errmsg(DWORD err, const char *text)
      * If text doesn't contains '(', negative precision is given, which is
      * treated as though it were missing.
      */
-    char *msg = NULL, *nul = strchr(text, '(');
+    char *msg = NULL;
+    const char *nul = strchr(text, '(');
     int len = nul ? nul - text : -1;
 
     FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
Signature · 1 line
2.30.2
#1 lore raw
Quoted 2 lines · Helge Konetzka

Compiling with clang++ of msys2 toolchain clang64 leads to an error on initializing 'char*' variable nul with a 'const char*' value

Can you include the error message in the description? I.e.:

'''
This fixes:

qga/vss-win32/install.cpp:49:24: error: cannot initialize a variable of type 'char *' with an rvalue of type 'const char *'

      char *msg = NULL, *nul = strchr(text, '(');
                         ^     ~~~~~~~~~~~~~~~~~

'''

Quoted 34 lines

---
Compiling with clang++ of msys2 toolchain clang64 leads to

[1445/1747] Compiling C++ object qga/vss-win32/qga-vss.dll.p/install.cpp.obj
FAILED: qga/vss-win32/qga-vss.dll.p/install.cpp.obj
...
qga/vss-win32/install.cpp:49:24: error: cannot initialize a variable of type 'char *' with an rvalue of type 'const char *'
    char *msg = NULL, *nul = strchr(text, '(');
                       ^     ~~~~~~~~~~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.
make: *** [Makefile:163: run-ninja] Error 1
==> ERROR: A failure occurred in build().
    Aborting...

---
  qga/vss-win32/install.cpp | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
qga/vss-win32/install.cpp +0 -0
index 8076efe3cb..b57508fbe0 100644
@@ -46,7 +46,8 @@ void errmsg(DWORD err, const char *text)
       * If text doesn't contains '(', negative precision is given, 

which is
      * treated as though it were missing.
      */
-    char *msg = NULL, *nul = strchr(text, '(');
+    char *msg = NULL;
+    const char *nul = strchr(text, '(');
     int len = nul ? nul - text : -1;

     FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |

Reviewed-by
#2 lore raw
In reply to Helge Konetzka
Quoted 5 lines · Helge Konetzka

Compiling with clang++ of msys2 toolchain clang64 leads to an error on initializing 'char*' variable nul with a 'const char*' value

Quoted 40 lines

---
Compiling with clang++ of msys2 toolchain clang64 leads to

[1445/1747] Compiling C++ object qga/vss-win32/qga-vss.dll.p/install.cpp.obj
FAILED: qga/vss-win32/qga-vss.dll.p/install.cpp.obj
...
qga/vss-win32/install.cpp:49:24: error: cannot initialize a variable of type 'char *' with an rvalue of type 'const char *'

     char *msg = NULL, *nul = strchr(text, '(');
                        ^     ~~~~~~~~~~~~~~~~~

1 error generated.
ninja: build stopped: subcommand failed.
make: *** [Makefile:163: run-ninja] Error 1
==> ERROR: A failure occurred in build().

     Aborting...
---
  qga/vss-win32/install.cpp | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
qga/vss-win32/install.cpp +0 -0
index 8076efe3cb..b57508fbe0 100644
@@ -46,7 +46,8 @@ void errmsg(DWORD err, const char *text)
       * If text doesn't contains '(', negative precision is given, which

is
* treated as though it were missing.
*/

qga/vss-win32/install.cpp +2 -2
-    char *msg = NULL, *nul = strchr(text, '(');
+    char *msg = NULL;
+    const char *nul = strchr(text, '(');
      int len = nul ? nul - text : -1;
 
      FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
--

2.30.2

Signature · 1 line
Marc-André Lureau