[omniORB] (no subject)

Tim Theisen ttheisen at tomotherapy.com
Thu May 26 09:18:49 BST 2005


I have an application that uses omniORB and runs on Linux and Windows.
Recently, I wrote some code that would not compile on Windows.
Constants defined within the idl file could not be used as cases within
a switch statement.  It turns out that these constants are initialized
differently when using a Microsoft compiler.  Upon reading the comments
in the CORBA_sysdep.h file, I came to the conclusion that the code was
working around a limitation in VC 6.  I modified the header file to do
that same thing for VC 7.1 as linux, and then the program compiled and
ran fine.  I have included the patch and hope that you would consider
including it in the next release.

$ diff -u CORBA_sysdep.h.orig CORBA_sysdep.h
--- CORBA_sysdep.h.orig 2004-10-17 15:14:28.000000000 -0500
+++ CORBA_sysdep.h      2005-05-25 16:11:53.368092800 -0500
@@ -389,7 +389,7 @@
 #endif

 #ifndef _init_in_cldecl_
-#  if !defined(_MSC_VER)
+#  if !defined(_MSC_VER) || _MSC_VER >= 1310
 #    define _init_in_cldecl_(x) x
 #  else
 #    define _init_in_cldecl_(x)
@@ -399,7 +399,7 @@
 #endif

 #ifndef _init_in_cldef_
-#  if !defined(_MSC_VER)
+#  if !defined(_MSC_VER) || _MSC_VER >= 1310
 #    define _init_in_cldef_(x)
 #  else
 #    define _init_in_cldef_(x) x


Here are small code snippets that can be used to demonstrate the
problem.
===== job.idl =====
module tcalc {
    typedef long EventID;
    interface Job {
        const EventID STARTED = 0;
        const EventID STOPPED = 1;
    };
};

===== main.cpp =====
#include <iostream>
#include "job_idl.hpp"

int
main(int argc, const char* argv[]) {
#if defined(_MSC_VER)
    std::cout << _MSC_VER << std::endl;
#endif
    using namespace tcalc;
    EventID id = Job::STARTED;
    switch(id) {
        case Job::STARTED:
            std::cout <<"Started!:" << std::endl;
            break;
        default:
            std::cout <<"Not started!:" << std::endl;
    }
}
===== =====
...Tim
--
       Tim Theisen                     Lead Research Software Engineer
Phone: +1 608 824 2848                 TomoTherapy Incorporated
  Fax: +1 608 824 2996                 1240 Deming Way
  Web: http://www.tomotherapy.com      Madison, WI 53717-1954  




More information about the omniORB-list mailing list