LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

string情報のDLLプログラムについて

構造体にstring型を入れたdllプログラムを作成したところ強制終了となりました。

また、dllプログラムで参照として、string型を出力したところ文字化けが発生しました。

どのようなdllプログラムだとstring型を扱えるようになるのでしょうか。

下記がdllプログラムのコードになります。

c++で作成しました。

 


//#include "stdafx.h"

//#include "extcode.h"
#include <windows.h>
#include<iostream>
#include <string>


//using namespace std;

typedef struct{
double in1;
//std::string in2;
}TD1;


_declspec(dllexport) void String_check(TD1* input, TD1* output, std::string* mozi);

_declspec(dllexport) void String_check(TD1* input, TD1* output, std::string* mozi)
{
output->in1 = input->in1 * 2;
//output->in2 = "12345";
*mozi = "12345";
}

Download All
0 Kudos
Message 1 of 2
(494 Views)

A C++ data type can NOT be transferred from LabVIEW to a DLL and back! Period!

 

The main reason is that C++ object classes are not standardized in terms of memory layout. Each compiler tends to do its own memory layout. This also means that you can generally not call a C++ DLL created in compiler A by a program created in compiler B, unless you restrict the interface between the two to pure C datatypes.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 2
(458 Views)