Author Topic: Compiler warning during compiling wxSmith  (Read 563 times)

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2417
Compiler warning during compiling wxSmith
« on: May 26, 2019, 02:00:18 am »
Hi, this probably is not the right place to ask, but anyway:
I compile wxSmith and get this warning:
Code: [Select]
\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]
for function:
Code: [Select]
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);
}

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.

So
Code: [Select]
va_start(ap,Fmt.c_str()); should actually be
Code: [Select]
va_start(ap,Fmt);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.
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.
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"....

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11899
    • Travis build status
Re: Compiler warning during compiling wxSmith
« Reply #1 on: May 26, 2019, 02:28:56 am »
See how wxString::Format is implemented and what type it uses.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2417
Re: Compiler warning during compiling wxSmith
« Reply #2 on: May 27, 2019, 12:08:01 am »
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...

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11899
    • Travis build status
Re: Compiler warning during compiling wxSmith
« Reply #3 on: May 27, 2019, 08:42:46 am »
wx is c++<11, so I doubt the use variadic templates.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2417
Re: Compiler warning during compiling wxSmith
« Reply #4 on: May 27, 2019, 01:01:20 pm »