xpidl and #ifdef

You may be surprised to find that the Mozilla xpidl compiler doesn't support #ifdef, which seems to be the right way to conditionally define members in your IDL files. So how are you supposed to define debug-only stuff, for example?

Turns out it's quite possible through a flexible passthrough mechanism. Just wrap your C++-isms in blocks like this:

%{C++
#ifdef DEBUG
%}
    readonly attribute long myDebugStuff;
%{C++
#endif
%}

This will appear as expected in the generated .h file. Thanks, Darin, for the tip!

Update 2/22/2007: This is just enough rope to hang yourself. Be careful about mismatches between the caller and callee's understanding of the vtable layout!

Categories

Leave a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About this Entry

This page contains a single entry by Mike Tsao published on January 11, 2007 1:24 PM.

Unsubscribe Ars Technica was the previous entry in this blog.

Digital TV is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.2-en