Call_External Errors in IDL 5.5

QUESTION: I have a found a difference between CALL_EXTERNAL for IDL 5.4.1 and IDL 5.5. One of my routines crashes in IDL 5.5. Does anyone know why this would be so?

ANSWER: This answer was provided on the IDL newsgroup by Mark Rivers, the newsgroup expert on things external to IDL.

There is one very important difference between CALL_EXTERNAL in IDL 5.5 and previous versions, which has to do with how IDL strings are passed. The following code is from "export.h" in IDL 5.5.

********************************************
typedef int IDL_STRING_SLEN_T;
#define IDL_STRING_MAX_SLEN 2147483647


typedef struct {                /* Define string descriptor */
  IDL_STRING_SLEN_T slen;       /* Length of string, 0 for null */
  short stype;                  /* type of string, static or dynamic */
  char *s;                      /* Addr of string */
} IDL_STRING;
********************************************

Note that "slen" is of type "int". In previous versions it was of type "short". Thus, if your external C code is being passed strings it needs to be changed for IDL 5.5.

I worked around this problem, making a single DLL that will work for any IDL version, by changing my IDL wrapper routines and C code to never pass strings, but convert everything to byte arrays before CALL_EXTERNAL, and back to strings after CALL_EXTERNAL.

Google
 
Web Coyote's Guide to IDL Programming