Init.cpp
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006 Chris Cannam.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #include <iostream>
17 
18 #include <qglobal.h>
19 
20 #ifdef Q_OS_WIN32
21 
22 #include <fcntl.h>
23 
24 // required for SetDllDirectory
25 #define _WIN32_WINNT 0x0502
26 #include <windows.h>
27 
28 // Set default file open mode to binary
29 //#undef _fmode
30 //int _fmode = _O_BINARY;
31 
32 void redirectStderr()
33 {
34 #ifdef NO_PROBABLY_NOT
35  HANDLE stderrHandle = GetStdHandle(STD_ERROR_HANDLE);
36  if (!stderrHandle) return;
37 
38  AllocConsole();
39 
40  CONSOLE_SCREEN_BUFFER_INFO info;
41  GetConsoleScreenBufferInfo(stderrHandle, &info);
42  info.dwSize.Y = 1000;
43  SetConsoleScreenBufferSize(stderrHandle, info.dwSize);
44 
45  int h = _open_osfhandle((long)stderrHandle, _O_TEXT);
46  if (h) {
47  FILE *fd = _fdopen(h, "w");
48  if (fd) {
49  *stderr = *fd;
50  setvbuf(stderr, NULL, _IONBF, 0);
51  }
52  }
53 #endif
54 }
55 
56 #endif
57 
59 {
60 #ifdef Q_OS_WIN32
61  redirectStderr();
62 
63  // Remove the CWD from the DLL search path, just in case
64  SetDllDirectory(L"");
65  putenv("PATH=");
66 
67  // Some older versions of MinGW require this in order to get
68  // C99/POSIX-standard behaviour for (s)printf formatting
69  putenv("PRINTF_EXPONENT_DIGITS=2");
70 #else
71 #endif
72 }
73 
void svSystemSpecificInitialisation()
Definition: Init.cpp:58