Tôi gặp sự cố tương tự (mặc dù trong C++) với macro SNAP_LISTEN (...) của tôi như được định nghĩa bên dưới. Giải pháp duy nhất tôi tìm thấy là tạo một macro mới SNAP_LISTEN0 (...) không bao gồm tham số args .... Tôi không thấy một giải pháp nào khác trong trường hợp của tôi. Tùy chọn dòng lệnh -Wno-variadic-macros ngăn cảnh báo variadic chứ không phải cảnh báo ISO C99!
#define SNAP_LISTEN(name, emitter_name, emitter_class, signal, args...) \
if(::snap::plugins::exists(emitter_name)) \
emitter_class::instance()->signal_listen_##signal(\
boost::bind(&name::on_##signal, this, ##args));
#define SNAP_LISTEN0(name, emitter_name, emitter_class, signal) \
if(::snap::plugins::exists(emitter_name)) \
emitter_class::instance()->signal_listen_##signal(\
boost::bind(&name::on_##signal, this));
Chỉnh sửa: trình biên dịch phiên bản
g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Edit: cảnh báo dòng lệnh
set(CMAKE_CXX_FLAGS "-Werror -Wall -Wextra -pedantic -std=c++0x
-Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization
-Wformat=2 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wnoexcept
-Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow
-Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default
-Wundef -Wno-unused -Wno-variadic-macros -Wno-parentheses
-fdiagnostics-show-option")
Các -Wno-variadic-macro tự làm việc kể từ khi tôi không nhận được một lỗi nói rằng variadic không được chấp nhận. Tuy nhiên, tôi nhận được lỗi tương tự như Matt Joiner:
cpfs.c:232:33: warning: ISO C99 requires rest arguments to be used
Nguồn
2012-10-14 07:31:17
Điều đó làm tôi bối rối trong một thời gian quá. Trên thực tế, cách tiêu chuẩn sẽ là 'log_debug ("% s "," Đặt lại bitmap ");'. – Dummy00001
Làm thế nào kỳ quặc mà các dấu chấm lửng tiền xử lý thay thế cho một hoặc nhiều đối số, nhưng dấu ba chấm C thay thế cho số không hoặc nhiều hơn. Tôi đang gặp một số rắc rối khi trích xuất ngữ nghĩa này từ chuẩn C99. –