Skip to content

Commit 93eb2fc

Browse files
committed
avoid build failure on gcc
1 parent e2a33d4 commit 93eb2fc

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

examples/cli/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ struct SDParams {
8181
bool vae_tiling = false;
8282
};
8383

84-
static std::string basename(const std::string& path) {
84+
static std::string sd_basename(const std::string& path) {
8585
size_t pos = path.find_last_of('/');
8686
if (pos != std::string::npos) {
8787
return path.substr(pos + 1);
@@ -443,7 +443,7 @@ std::string get_image_params(SDParams params, int64_t seed) {
443443
parameter_string += "CFG scale: " + std::to_string(params.cfg_scale) + ", ";
444444
parameter_string += "Seed: " + std::to_string(seed) + ", ";
445445
parameter_string += "Size: " + std::to_string(params.width) + "x" + std::to_string(params.height) + ", ";
446-
parameter_string += "Model: " + basename(params.model_path) + ", ";
446+
parameter_string += "Model: " + sd_basename(params.model_path) + ", ";
447447
parameter_string += "RNG: " + std::string(rng_type_to_str[params.rng_type]) + ", ";
448448
parameter_string += "Sampler: " + std::string(sample_method_str[params.sample_method]);
449449
if (params.schedule == KARRAS) {

stable-diffusion.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,18 @@ enum sd_type_t {
7979

8080
SD_API const char* sd_type_name(enum sd_type_t type);
8181

82+
enum sd_log_level_t {
83+
SD_LOG_DEBUG,
84+
SD_LOG_INFO,
85+
SD_LOG_WARN,
86+
SD_LOG_ERROR
87+
};
88+
8289
typedef void (*sd_log_cb_t)(enum sd_log_level_t level, const char* text, void* data);
8390

8491
SD_API void sd_set_log_callback(sd_log_cb_t sd_log_cb, void* data);
8592
SD_API int32_t get_num_physical_cores();
93+
SD_API const char* sd_get_system_info();
8694

8795
typedef struct {
8896
uint32_t width;
@@ -133,15 +141,6 @@ SD_API sd_image_t* img2img(sd_ctx_t* sd_ctx,
133141
int64_t seed,
134142
int batch_count);
135143

136-
SD_API const char* sd_get_system_info();
137-
138-
enum sd_log_level_t {
139-
SD_LOG_DEBUG,
140-
SD_LOG_INFO,
141-
SD_LOG_WARN,
142-
SD_LOG_ERROR
143-
};
144-
145144
typedef struct upscaler_ctx_t upscaler_ctx_t;
146145

147146
SD_API upscaler_ctx_t* new_upscaler_ctx(const char* esrgan_path,

util.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <fstream>
66
#include <locale>
77
#include <sstream>
8+
#include <string>
89
#include <thread>
910
#include <unordered_set>
1011
#include <vector>
@@ -140,7 +141,7 @@ std::u32string unicode_value_to_utf32(int unicode_value) {
140141
return utf32_string;
141142
}
142143

143-
std::string basename(const std::string& path) {
144+
std::string sd_basename(const std::string& path) {
144145
size_t pos = path.find_last_of('/');
145146
if (pos != std::string::npos) {
146147
return path.substr(pos + 1);
@@ -211,7 +212,7 @@ void log_printf(sd_log_level_t level, const char* file, int line, const char* fo
211212

212213
static char log_buffer[LOG_BUFFER_SIZE];
213214

214-
int written = snprintf(log_buffer, LOG_BUFFER_SIZE, "[%s] %s:%-4d - ", level_str, basename(file).c_str(), line);
215+
int written = snprintf(log_buffer, LOG_BUFFER_SIZE, "[%s] %s:%-4d - ", level_str, sd_basename(file).c_str(), line);
215216

216217
if (written >= 0 && written < LOG_BUFFER_SIZE) {
217218
vsnprintf(log_buffer + written, LOG_BUFFER_SIZE - written, format, args);

util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ std::u32string utf8_to_utf32(const std::string& utf8_str);
2020
std::string utf32_to_utf8(const std::u32string& utf32_str);
2121
std::u32string unicode_value_to_utf32(int unicode_value);
2222

23-
std::string basename(const std::string& path);
23+
std::string sd_basename(const std::string& path);
2424

2525
std::string path_join(const std::string& p1, const std::string& p2);
2626

0 commit comments

Comments
 (0)