Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 333563

Summary: Compiling starter.exe having DEBUG_MONITOR defined fails when using Mingw/MSYS
Product: [Tools] CDT Reporter: Raphael Zulliger <zulliger>
Component: cdt-coreAssignee: Project Inbox <cdt-core-inbox>
Status: NEW --- QA Contact: Jonah Graham <jonah>
Severity: minor    
Priority: P3    
Version: 8.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Raphael Zulliger CLA 2011-01-05 07:56:37 EST
Build Identifier: 20100617-1415

I've got Mingw/MSYS running on Windows 7 (64Bit) using gcc-4.5 and w32api-3.14.

I had to get some more information out from starter.exe to debug an issue. Therfore, I manually uncommented
  //#define DEBUG_MONITOR 
in starter.cpp. After that, compiling the sources failed (it perfectly worked before my change). I got the following failures (shortened):

  $ make
  g++ -DUNICODE    -c -o starter.o starter.cpp
  starter.cpp: In function 'int main()':
  starter.cpp:161:53: error: cannot convert 'const char*' to 'const WCHAR*' for argument '1' to 'void OutputDebugStringW(const WCHAR*)'
  ...

It seemed to me like a UNICODE issue. Therefore I started VC2008 and created a "new project" to see what compiler directives they use when compiling with UNICODE support. Among others, they pass the following directives to the compiler: 
  /D "_UNICODE" /D "UNICODE"
Because of that, my conclusion is that the makefile for starter.exe is missing the following additional directive:
  _UNICODE
(note the prefixed underscore). After having adjusted the makefile to
  CXXFLAGS = -DUNICODE -D_UNICODE
The compilation errors were gone (and, according to my tests) starter.exe worked like a charm!

As the fix is trivial, it could be worth the effort of doing it.

Reproducible: Always

Steps to Reproduce:
1. Prepare the environment described above
2. issue a 'make' in an msys console