Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Daten von Delphi an C++ übergeben

Empfohlene Antworten

Veröffentlicht

Hallo ihr,

ich möchte Daten von einem Delphiprogramm an eine in C++ geschriebene DLL übertragen. Und möchte nun herrausfinden auf was ich da alles achten muss.

Ich habe schon erfolgreich primitven Datentypen von Delphi an die C++ DLL geschickt das klappt also soweit.

Nun habe ich zum Test mal ein Array vom typ double von Delphi an C++ geschickt. Doch wenn ich mir dann das Array anschaue was in C++ ankomme stehen da zwar die Werte drinne die ich von Delphiseite her reingebe. Jedoch wird das 2. Element des Arrays an der letzten Stelle des doubles verfälscht.

Nun wollte ich wissen ob das ganz normale ungenaugkeiten sind die durch den EInsatz von Fließkommazahlen kommen oder ob ich da etwas nicht beachtet habe.

Hier nun ein bisschen Quellcode für euch:

Delphi



type Daten = record

doubles : array[0..3] of double;

end;



// das sind die Werte die der record annimmt

 m_OptiData.doubles[0]:=1.337;

  m_OptiData.doubles[1]:=1.338;

   m_OptiData.doubles[2]:=1.339;



C++ Seite:
struct Daten

{


	double doubles[3];




};





DLLEXPORT int __stdcall MOPTI_execute(ROptimizationData * pData)

{


// daten testweise auf console ausgeben


	cout << pData->doubles[0] << endl;  // gibt 1.3370000000000000 aus

	cout << pData->doubles[1] << endl; // gibt 1.3380000000000001 aus

	cout << pData->doubles[2] << endl; // gibt 1.3390000000000000 aus



OK ja sind die ganz normalen Ungenauigkeiten von double.

Jetzt noch die Frage ob jemand sowas schonmal gemacht hat und da Erfahrungen hat auf was man so achten sollte?

Im Endeffekt sollen records von Delphi an C++ übergeben werden.

DIese Records bestehen aus arrays von daten und auch wiederum teilweise aus records. (Also nur die Grundstruktur ist festgelegt (z.b. record record array array record record) nicht aber die anzahl der Elemente im Array z.B)

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.