Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Compiler warning during compiling wxSmith
(1/1)
BlueHazzard:
Hi, this probably is not the right place to ask, but anyway:
I compile wxSmith and get this warning:
--- Code: ---\src\plugins\contrib\wxSmith\wxwidgets\wxsitem.cpp: In member function 'void wxsItem::Codef(const wxString&, ...)':
\src\plugins\contrib\wxSmith\wxwidgets\wxsitem.cpp:525:29: warning: second parameter of 'va_start' not last named argument [-Wvarargs]
--- End code ---
for function:
--- Code: ---void wxsItem::Codef(const wxString &Fmt,...)
{
if ( !GetCoderContext() )
{
// TODO: Debug log
return;
}
va_list ap;
va_start(ap,Fmt.c_str());
Codef(GetCoderContext(),Fmt,GetCoderContext()->m_BuildingCode,ap);
va_end(ap);
}
--- End code ---
now i read the documentation:
--- Quote ---void va_start (va_list ap, paramN);
paramN
Name of the last named parameter in the function definition. The arguments extracted by subsequent calls to va_arg are those after paramN.
--- End quote ---
So
--- Code: ---va_start(ap,Fmt.c_str());
--- End code ---
should actually be
--- Code: ---va_start(ap,Fmt);
--- End code ---
but there is a warning in the documentation:
--- Quote ---The parameter shall not be of a reference type, or of a type that is not compatible with the type that results when passing an argument for which there is no parameter.
--- End quote ---
or
--- Quote ---If parm_n is declared with reference type or with a type not compatible with the type that results from default argument promotions, the behavior is undefined.
--- End quote ---
So i can not use a reference here? I have tested it and it seems to work at least with gcc5, but i do not like this "undefined"....
oBFusCATed:
See how wxString::Format is implemented and what type it uses.
BlueHazzard:
As far as i can see they use some fancy template magic...
I will look if it is worth to replace the actual code with variadic templates, but i do not think it is worth... On GCC it works, on MSVC (or how it is called...) it won't work, but we do not compile codelocks with MSVC so there should not be a problem...
oBFusCATed:
wx is c++<11, so I doubt the use variadic templates.
BlueHazzard:
yea, i was wrong... it is macro magic https://github.com/wxWidgets/wxWidgets/blob/master/include/wx/strvararg.h
Navigation
[0] Message Index
Go to full version