From: Paul Brannan Date: 2001-12-14T07:06:58+09:00 Subject: [ruby-talk:28463] Re: ANNOUNCE: Extending Ruby With C++ Mini On Fri, Dec 14, 2001 at 06:27:08AM +0900, Issac Trotts wrote: > The GNU C++ compiler didn't like 'extern "C" static VALUE foo() { ... }', > warning that it's a mix of storage classes or something like that. > The namespace idea should be fine though. The compiler is correct. "static" in front of a function name means that function has file scope, and is not visible from outside the file. "extern" means that the function is visible from outside the file. These two keywords cannot be used together. > Sure. Maybe I should include something about this later in the > HOW-TO. What sorts of exceptions could be thrown by the > code I wrote? Maybe the 10-element int array wouldn't get allocated > it seems like that will almost never happen. std::vector::push_back() can throw an std::bad_alloc. This is probably a rare condition, but if you can handle this exception then you can handle the case where you aren't using built-in types. If I have a user-defined type Foo, and I create a vector of Foo, and Foo's constructor throws a FooException in certain cases, then I need to be prepared to handle that exception (preferably genericly, so that if I decide to use a vector instead, and Bar's constructor throws a BarException, my code will continue to remain exception-safe). If you enable exceptions on cout, then there are many exceptions that could be thrown; these all inherit from std::ios::failure. An example of when such an exception might be thrown is if stdout is being redirected to a file, and you run out of disk space. > Good points. Thanks for the input. Nice job on the mini-howto, btw. I wish I had time to write many similar documents myself, but there is so much to do and so little time... :) Paul