extending ruby: ruby_init() instacloses process

  • Thread starter Nilbert Nullingsworth
  • Start date
N

Nilbert Nullingsworth

Hey guys, I am extending ruby in a C++ program. I have all the headers
set up and stuff so it compiles without error, but I do get one
warning (MSVC Express 2008):

c:\visual studio 2008\projects\remoteexec\remoteexec\rubyheaders\ruby/
missing.h(154) : warning C4273: 'vsnprintf' : inconsistent dll linkage
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\stdio.h(350) :
see previous definition of 'vsnprintf'

Because it doesn't keep it from compiling, I don't think this is the
source of my problem. The problem is, when I call ruby_init() to start
the interpreter, the program instantly terminates. Run by the command
line, it looks like this:

C:\Visual Studio 2008\Projects\remoteExec\Release>project.exe

C:\Visual Studio 2008\Projects\remoteExec\Release>

As you can see, it does nothing. There are no errors, even though my
code is wrapped in a try/catch thing. Here is the C++ Code:

#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include "ruby.h"

using namespace std;

int main() {
//copied from teh internetz
/*HWND hWnd = GetConsoleWindow();
ShowWindow(hWnd, SW_HIDE);*/

try {
ruby_init();
} catch (char* e) {
cout << e;
}

system("PAUSE");

return 0;
}

This code isn't supposed to do anything, it's just confining the error
to that one line. No error is outputted and the program does not pause
after executing the try/catch, like it should with system("PAUSE").
Does anyone know why it is just stopping the program when ruby_init()
is called? I am using the ruby 1.9 libs and headers and stuff.
 
N

Nilbert Nullingsworth

Also as you can see, I have commented out the code that would have
stopped the console window from displaying, as I thought it may have
been the source of the problem. However, as evidenced by the command
line and the fact that no process that belongs to the program is
running, the program is indeed ceasing to exist upon reaching the
ruby_init(); line.
 
N

Nilbert Nullingsworth

Actually, placing ruby_init() anywhere in the file closes the program
instantly. Replacing the try/catch block above with this one:

try {
printf("ARGGGGGGGGGGGGGGGGGG");

printf("asdf");

ruby_init();
} catch (char* e) {
printf("%s", e);
}

and running the program via command line does not print anything.
What the heck. Anyone have any idea why the bloody blazes this is
happening?
 
E

Eric Christopherson

Actually, placing ruby_init() anywhere in the file closes the program
instantly. Replacing the try/catch block above with this one:

try {
=A0 =A0 =A0 =A0printf("ARGGGGGGGGGGGGGGGGGG");

=A0 =A0 =A0 =A0printf("asdf");

=A0 =A0 =A0 =A0ruby_init();
} catch (char* e) {
=A0 =A0 =A0 =A0printf("%s", e);
}

and running the program via command line does not print anything.
What the heck. Anyone have any idea why the bloody blazes this is
happening?

No idea, but I got it to run smoothly when compiled with MinGW (for
what little it's worth).
 
N

Nilbert Nullingsworth

Well, I may just have to learn how to use MinGW if no one can figure
out why VC++ is messing it up.
 
E

Eric Christopherson

Well, I may just have to learn how to use MinGW if no one can figure
out why VC++ is messing it up.

Back to that vsnprintf warning, what happens if you remove #include <cstdio>?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,744
Latest member
CortneyMcK

Latest Threads

Top