godotengine / godot-cpp

C++ bindings for the Godot script API
MIT License
1.74k stars 576 forks source link

Warning: format '%s' expects argument of type 'char*', but argument has type 'godot::String*' #178

Closed capnm closed 6 years ago

capnm commented 6 years ago

gcc --version gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0

git log -1 commit f7fafbbba4aaa7b2695ebc88d1648feeea8eeb18 (HEAD -> nativescript-1.1, origin/nativescript-1.1) Merge: 12aeafd d7236d3 Date: Wed Aug 15 08:58:03 2018 +0200

…

g++ -o src/core/Color.o -c -fPIC -g -Og -std=c++14 -Wwrite-strings -Og -m64 -I. -Igodot_headers -Iinclude -Iinclude/gen -Iinclude/core src/core/Color.cpp
In file included from src/core/Color.cpp:2:0:
src/core/Color.cpp: In static member function 'static godot::Color godot::Color::html(const godot::String&)':
include/core/Defs.hpp:120:54: warning: format '%s' expects argument of type 'char*', but argument 3 has type 'godot::String*' [-Wformat=]
 #define ERR_PRINT(x) fprintf(stderr, "ERROR: %s\n", x)
                                                      ^
include/core/Defs.hpp:124:25: note: in expansion of macro 'ERR_PRINT'
 #define ERR_PRINTS(msg) ERR_PRINT(msg.utf8().get_data())
                         ^~~~~~~~~
src/core/Color.cpp:272:3: note: in expansion of macro 'ERR_PRINTS'
   ERR_PRINTS(String("Invalid Color Code: ") + p_color);
   ^~~~~~~~~~
include/core/Defs.hpp:120:54: warning: format '%s' expects argument of type 'char*', but argument 3 has type 'godot::String*' [-Wformat=]
 #define ERR_PRINT(x) fprintf(stderr, "ERROR: %s\n", x)
                                                      ^
include/core/Defs.hpp:124:25: note: in expansion of macro 'ERR_PRINT'
 #define ERR_PRINTS(msg) ERR_PRINT(msg.utf8().get_data())
                         ^~~~~~~~~
src/core/Color.cpp:280:4: note: in expansion of macro 'ERR_PRINTS'
    ERR_PRINTS(String("Invalid Color Code: ") + p_color);
    ^~~~~~~~~~
include/core/Defs.hpp:120:54: warning: format '%s' expects argument of type 'char*', but argument 3 has type 'godot::String*' [-Wformat=]
 #define ERR_PRINT(x) fprintf(stderr, "ERROR: %s\n", x)
                                                      ^
include/core/Defs.hpp:124:25: note: in expansion of macro 'ERR_PRINT'
 #define ERR_PRINTS(msg) ERR_PRINT(msg.utf8().get_data())
                         ^~~~~~~~~
src/core/Color.cpp:289:3: note: in expansion of macro 'ERR_PRINTS'
   ERR_PRINTS(String("Invalid Color Code: ") + p_color);
   ^~~~~~~~~~
include/core/Defs.hpp:120:54: warning: format '%s' expects argument of type 'char*', but argument 3 has type 'godot::String*' [-Wformat=]
 #define ERR_PRINT(x) fprintf(stderr, "ERROR: %s\n", x)
                                                      ^
include/core/Defs.hpp:124:25: note: in expansion of macro 'ERR_PRINT'
 #define ERR_PRINTS(msg) ERR_PRINT(msg.utf8().get_data())
                         ^~~~~~~~~
src/core/Color.cpp:294:3: note: in expansion of macro 'ERR_PRINTS'
   ERR_PRINTS(String("Invalid Color Code: ") + p_color);
   ^~~~~~~~~~
include/core/Defs.hpp:120:54: warning: format '%s' expects argument of type 'char*', but argument 3 has type 'godot::String*' [-Wformat=]
 #define ERR_PRINT(x) fprintf(stderr, "ERROR: %s\n", x)
                                                      ^
include/core/Defs.hpp:124:25: note: in expansion of macro 'ERR_PRINT'
 #define ERR_PRINTS(msg) ERR_PRINT(msg.utf8().get_data())
                         ^~~~~~~~~
src/core/Color.cpp:299:3: note: in expansion of macro 'ERR_PRINTS'
   ERR_PRINTS(String("Invalid Color Code: ") + p_color);
   ^~~~~~~~~~
xfxdev commented 6 years ago

@capnm See https://github.com/GodotNativeTools/godot-cpp/pull/186

Change

#define WARN_PRINTS(msg) WARN_PRINT(msg.utf8().get_data())
#define ERR_PRINTS(msg) ERR_PRINT(msg.utf8().get_data())

To

#define WARN_PRINTS(msg) WARN_PRINT((msg).utf8().get_data())
#define ERR_PRINTS(msg) ERR_PRINT((msg).utf8().get_data())
capnm commented 6 years ago

Thanks!