[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[TRNSYS-users] Problems when implementing TYPE in C/C++



Dear David and Werner, Javier,
(and users who want to write a new TYPE in C/C++)

I summarized the problems when implementing a TYPE in C++.

1. TRNSYS.h
 There are some errors in prototype definitions.
  - the argument problems ( by reference vs. by value )
   It can be solved to replace like 'int' to 'int*' in prototype
   definitions.
  - incompatibility between 'logical' in Fortran and 'bool' in C++
   Replace 'bool' to 'char'( -1 is true, and 0 is false in C++. )

2. C/C++ runtime library problems
  - Functions to access TRNSYS global variables and return 'char*'(string)
    are crashed due to inconsistent runtime library.

    Users have to compile a DLL with the same combination of Trnlib.dll.
    (Open trnlib.dll with Dependency Walker and check the runtime
     libraries(msvcrt.dll and dforrt.dll))

  - Trnlib.dll in the package is linked with like below.

   Trnlib.dll - dfortd.dll(Debug) - msvcrtd.dll(Debug)
        |
       ...
        |
        ------- msvcrt.dll(Release)
Debug and release version of C/C++ runtime are mixed.  I guess
this is a cause of the crash.

3. Sharing a logical unit between trnlib.dll and user-defined dll.
  - I have not succeeded in my dll written in C++, although Werner said
    it is possible.
  - In the case of writing a new TYPE in Fortran, be careful to use 
    consistent library with Trnlib.dll(debug vs. release). 

If user does not want to use any kernel functions and 
not require any file, do not care what I explained here.

Yoshihiro

=====================================
  Yoshihiro Yamaguchi    山口 芳弘  
  yamaguti@alpha-net.ne.jp
=====================================