compile on win32

This commit is contained in:
David Rose 2009-08-31 19:31:28 +00:00
parent aebc5042f5
commit 671e3e5e85
6 changed files with 11 additions and 10 deletions

View File

@ -19,6 +19,7 @@
// pass around a handle to an open file object.
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
typedef HANDLE FHandle;
static const HANDLE invalid_fhandle = INVALID_HANDLE_VALUE;

View File

@ -109,7 +109,7 @@ main(int argc, char *argv[]) {
stringstream stream(interactive_console_str);
int flag;
stream >> flag;
if (stream) {
if (!stream.fail()) {
interactive_console = (flag != 0);
}
}

View File

@ -75,7 +75,7 @@ P3DPythonRun(const char *program_name, const char *archive_file,
// Open the error output before we do too much more.
_error_log.open_write(error_handle);
if (_error_log) {
if (!_error_log.fail()) {
// Set up the indicated error log as the Notify output.
_error_log.setf(ios::unitbuf);
Notify::ptr()->set_ostream_ptr(&_error_log, false);

View File

@ -974,7 +974,7 @@ start_p3dpython(P3DInstance *inst) {
NULL, CREATE_ALWAYS, 0, NULL);
if (handle != INVALID_HANDLE_VALUE) {
_error_handle = handle;
SetHandleInformation(error_handle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
SetHandleInformation(_error_handle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
_got_error_handle = true;
} else {
nout << "Unable to open " << _log_pathname << "\n";
@ -1240,7 +1240,7 @@ win_create_process() {
PROCESS_INFORMATION process_info;
BOOL result = CreateProcess
(_p3dpython_exe.c_str(), command_line, NULL, NULL, TRUE, 0,
(void *)_env.c_str(), _start_dir_cstr,
(void *)_env.c_str(), start_dir_cstr,
&startup_info, &process_info);
bool started_program = (result != 0);
@ -1372,15 +1372,15 @@ p3dpython_thread_run() {
size_t zero = _env.find('\0', p);
while (zero != string::npos) {
const char *start = _env.data() + p;
#ifdef _WIN32
_putenv(start);
#else
const char *equals = strchr(start, '=');
if (equals != NULL) {
string variable(start, equals - start);
#ifdef _WIN32
_putenv_s(variable.c_str(), equals + 1);
#else
setenv(variable.c_str(), equals + 1, true);
#endif // _WIN32
}
#endif // _WIN32
p = zero + 1;
zero = _env.find('\0', p);
}

View File

@ -12,8 +12,8 @@
//
////////////////////////////////////////////////////////////////////
#include "run_p3dpython.h"
#include "p3dPythonRun.h"
#include "run_p3dpython.h"
////////////////////////////////////////////////////////////////////
// Function: run_p3dpython

View File

@ -31,7 +31,7 @@ run_p3dpython_func(const char *program_name, const char *archive_file,
FHandle input_handle, FHandle output_handle,
FHandle error_handle, bool interactive_console);
EXPCL_P3DPYTHON extern "C" bool
extern "C" EXPCL_P3DPYTHON bool
run_p3dpython(const char *program_name, const char *archive_file,
FHandle input_handle, FHandle output_handle,
FHandle error_handle, bool interactive_console);