Hi!

I have tried to extend/embed Ruby on Windows, but soon I encountered
problems. Ruby redefines several function names "owned" by the API:s
of the operating system and names used in C/C++ runtime library
headers files. This can lead to compilation errors and/or linking
errors. I think the main problem is the use of #define to re-define
some symbols to suit Ruby without taking into account that Ruby
doesn't own the symbols. This practice to steal the symbols is perhaps
not a problem when building Ruby itself. But when extending/embedding
it causes real problems.

Here is an example from Windows XP / Visual C++:

---------------------------------
#include <ruby.h>
#include <string>
// ... rest of file ...
---------------------------------

This code gives a compile error:

---------------------------------
C:/Program Files/Microsoft Visual Studio 8/VC/INCLUDE\ostream(532) :
warning C4003: not enough actual parameters for macro 'write'
C:/Program Files/Microsoft Visual Studio 8/VC/INCLUDE\ostream(531) :
error C2059: syntax error : ')'
---------------------------------

The reason is that Ruby has redefined "write" with a #define macro.
But there are functions in the C++ runtime library that have the same
name, e.g. "std::ostream::write". And a header file like "ostream"
doesn't expect "write" to expand into something else that only suits
Ruby.

Wouldn't it be better if the code used a prefix do avoid clashes in
the global namespace (as in the rb_* functions). Using #defines the
way it is used today I think is asking for trouble. I think this is
mainly a problem on Windows, since the #define settings are done more
there.

Is my analysis of the situation correct?

If so, I would like to see a "cleanup" of how global names are used to
avoid problems like this. I would be willing to help make the changes
needed if I only knew how you would like them to be done.

Regards,
/Johan Holmberg