Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6345365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:48:27+00:00 2026-05-24T20:48:27+00:00

I am writing a windows application in Lazarus/FreePascal (like Delphi). I have a TDataset

  • 0

I am writing a windows application in Lazarus/FreePascal (like Delphi). I have a TDataset object that is populated by 5000 rows, 2 columns of numerical values.
I need to pass this data to a C function that I am importing statically from a .dll library.

Here is an excerpt from the library’s manual that explains what format its parameters should be in:

flan_index_t flann_build_index(float* dataset,
    int rows,
    int cols,
    float* speedup,
    struct FLANNParameters* flann_params);

This function builds an index and return a reference to it. The
arguments expected by this function are as follows: dataset, rows and
cols – are used to specify the input dataset of points:
dataset is a pointer to a rows cols matrix stored in row-major
order (one feature on each row)

Can I simply pass the TDataSet object? Do I have to do something to it first so that the pointer is in the right form?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:48:28+00:00Added an answer on May 24, 2026 at 8:48 pm

    Obviously you can’t pass the TDataSet object. It is a FreePascal object, and the function seems to expect a pointer to a float (which is probably a pointer to a Single in FreePascal). It probably expects a two-dimensional array of float‘s. You have to pass another pointer to float and a pointer to a FLANNParameters structure as well.

    Move() won’t work either. A TDataSet is not an array.

    I guess you’ll have to declare an array like Uwe said, populate it using your dataset and pass the array:

    type
      PMyFloatArray = ^TFloatArray;
      TMyFloatArray = array[0..4999, 0..1] of Single;
    
    var
      MyArray: PMyFloatArray;
      idx: flan_index_t;
    
    begin
      New(MyArray);
      try
    
        // Fill array using your TDataSet...
        // set up other parameters... 
    
        idx := flann_build_index(MyArray, 5000, 2, &speedup, etc...);
    
        // ...
    
      finally
        Dispose(MyArray);
      end;
    end;     
    

    Shameless plug

    Please read my Pitfalls of Conversion article about converting function declarations from C to Delphi (and probably FreePascal on Win32). Now I’m at it, you may want to read my article Addressing Pointers too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application I'm writing for Windows 8/WinRT that uses the StreamSocket API
I have a C++ Windows application that can be extended by writing C++ plugins,
I am writing a Windows CE application in C# that references a native C++
I'm writing a windows service application that needs to serialize and deserialize XML documents
I'm writing a windows service in C# that spawns multiple instances of another application
We're writing an application for Windows tablet PCs. I have created a custom control
I'm writing a windows application using VS2010 and C# 4.0. I have a MDI
I'm writing an Windows Forms application that reads a file, processes it and then
I am writing a Windows application that will connect to a Sybase database through
I'm writing a Windows application that displays its tray icon on the Windows system

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.