Package: mingw-w64-dev
Version: 3.0~svn4933-1
Severity: normal
Tags: upstream

Hi Stephen,

Here is hopefully the last compile issue of ptlib/opal/ekiga chain
using mingw-w64:

Suppose the following program (b.cpp):
//#include <dshow.h>

//#undef sprintf
//#define sprintf sprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA;

class PString
{
public:
  PString & sprintf(const char * cfmt, ...);
};

PString & PString::sprintf(const char * fmt, ...)
{
  return *this;
}

int main (void)
{
  PString x;
  x.sprintf ("%d", 0);
  return 0;
}

When compiling it with "i686-w64-mingw32-g++ b.cpp" there is no error.

Uncommenting either the first line, or the 3rd and 4th lines, and
recompiling leads to an error:
$ i686-w64-mingw32-g++ b.cpp
b.cpp:9:21: error: expected unqualified-id before ‘const’
b.cpp:9:21: error: expected ‘)’ before ‘const’
b.cpp:12:20: error: ‘PString& 
PString::sprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA’ is not a 
static member of ‘class PString’
[...]

The problem is that dshow.h includes strsafe.h, which contains:
#undef sprintf
#define sprintf sprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA;
hence the error about not finding sprintf_instead_...

There are two bugs here:

1. Preventing use of the dangerous sprintf by using #define ... seems
not a good idea, since it prevents correct programs like the above to
compile.  Maybe they chose a simple solution which does not work on
the 0.1% of programs which use a method called "sprintf"?

2. The above #define sprintf... is put in strsafe.h, which is included
ONLY by dhow.h.  Shouldn't it be included by string.h or another much more
general header?!  In fact, "grep -r strsafe /usr/i686-w64-mingw32/include/"
shows:
/usr/i686-w64-mingw32/include/tchar.h:#error Need to include strsafe.h after 
tchar.h
/usr/i686-w64-mingw32/include/dshow.h:#include <strsafe.h>
/usr/i686-w64-mingw32/include/ddk/ntstrsafe.h: * FILE:            
include/ddk/ntstrsafe.h

Cheers,
Eugen

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.1.0-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

-- no debconf information



--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to